Re: [algogeeks] Re: Infinite Array

2011-09-30 Thread Ashima .
isnt this quest a lil wrong. coz suppose if i dnt know the length of an
array,then how will i  access the last element of the array.in such  a
case,i will almost traverse the whole memory and still not stop. coz
compiler does not give array out of bound exception.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 30, 2011 at 6:06 PM, pssaravanan
wrote:

> If the length of the array s not known,v could not apply the binary
> search to search for an element. i think following code will produce
> better solution.
>
> i = 0;
> for(i = 0;A[i] < p&& A[i] !=NULL;i = (i+1)^2);
> j = i;
> i = sqrt(i)-1;
> applybinarysearch(i,j);
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] without using '-'

2011-09-26 Thread Ashima .
grt.we never generally use ~ operator. got to knw abt it.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Mon, Sep 26, 2011 at 10:07 AM, ~*~VICKY~*~ wrote:

> Tricky question with more tricky answers. thank you all.
>
>
> On Mon, Sep 26, 2011 at 9:55 PM, Kunal Yadav wrote:
>
>> difference = x+ ~y +1
>>
>> On Mon, Sep 26, 2011 at 7:33 PM, ~*~VICKY~*~ wrote:
>>
>>> Find the difference of two numbers without using '-' operator !
>>>
>>> plz share ur solutions!
>>>
>>> --
>>> Cheers,
>>>
>>>   Vicky
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>>
>> --
>> Regards
>> Kunal Yadav
>> (http://sourcebit.in)
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Cheers,
>
>   Vicky
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] c doubt show me how smart u guys are

2011-09-25 Thread Ashima .
use radix sort 4 times. using bucket sort with chaining as the sorting
algorithm.
time complexity= O(4(n+k))
space complexity = O(n)
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sun, Sep 25, 2011 at 6:01 AM, Jasveen Singh wrote:

> i have a file 'star.txt' containing recordss in the form name score as
> given below
> *name   score*
> dave   52.67
> steve60.09
>
> and so on till 64 names
>
> i have to make a program to read and sort these names in a rank
> just show not to store
> all scores are in float and need to rank these names in a
> orderconsider these all students and teacher
> need a program to rank their percentage in an order to announce ranks
> lets see some algogeek magic
> what i did was
> create a static 2D array of 100 elements and store data from file in it
> using file handling(obvious)
> and then use a simple for loop ranking on 2nd line of array
>
> please need help guys
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] plz reply quickly

2011-09-23 Thread Ashima .
in hair and tortoise this they will meet wen 1st pointer(tortoise) is at the
end of the linked list(in 1st traverse) and 2nd pointer( hair) reaches the
same node 2nd time. That means u traversed the list twice.
Its better that since u hv the head of the linked list,  keep on moving till
the end .If next of end is head then its circular.
Rather for queue, u hv track of both front and rear, so just check if
rear->next ==front. One line code.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 23, 2011 at 8:13 AM, Aditya Virmani wrote:

> in arrays i guess it can be simply analysed checking the last element of
> array(which can be obtained by sizeof) & checking how the entries are filled
> inn the array...
> in linked list hair & tortoise rule...initialize two pointers...one's step
> size:1, second's step size two... & run through the linked list, if they
> meet newhere ...it contains a loop or circular list.
>
>
> On Thu, Sep 22, 2011 at 10:51 PM, sukran dhawan wrote:
>
>> use hair and tortoise rule for lists
>> i don think we can do it for arrays
>>
>>
>> On Thu, Sep 22, 2011 at 10:22 PM, Ishan Aggarwal <
>> ishan.aggarwal.1...@gmail.com> wrote:
>>
>>> In both the cases... what would be the condition?
>>>
>>>
>>> On Thu, Sep 22, 2011 at 10:19 PM, sukran dhawan 
>>> wrote:
>>>
>>>> queue represnted as array or linked list ?
>>>>
>>>>
>>>> On Thu, Sep 22, 2011 at 10:08 PM, Ishan Aggarwal <
>>>> ishan.aggarwal.1...@gmail.com> wrote:
>>>>
>>>>> How will u detect if a queue is circular or not??
>>>>>
>>>>> --
>>>>> Kind Regards
>>>>> Ishan Aggarwal
>>>>> [image: Aricent Group]
>>>>> Presidency Tower-A, M.G.Road,Sector-14
>>>>> Gurgaon,Haryana.122015 INDIA
>>>>> Phone : +91-9654602663
>>>>> ishan2.aggar...@aricent.com 
>>>>>
>>>>>  --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Kind Regards
>>> Ishan Aggarwal
>>> [image: Aricent Group]
>>> Presidency Tower-A, M.G.Road,Sector-14
>>> Gurgaon,Haryana.122015 INDIA
>>> Phone : +91-9654602663
>>> ishan2.aggar...@aricent.com 
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-19 Thread Ashima .
m getting  result in 95 matches
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Mon, Sep 19, 2011 at 7:07 PM, malay chakrabarti wrote:

> i have explained :)
>
> On Sun, Sep 18, 2011 at 11:53 PM, Ashima .  wrote:
>
>> @malay: how cm n+logn-2?
>> cn u explain the logic ?
>>
>> Ashima
>> M.Sc.(Tech)Information Systems
>>  4th year
>> BITS Pilani
>> Rajasthan
>>
>>
>>
>>
>>  On Sun, Sep 18, 2011 at 11:07 AM, Ashima . wrote:
>>
>>> rite! 62.5%
>>>
>>> Ashima
>>> M.Sc.(Tech)Information Systems
>>> 4th year
>>> BITS Pilani
>>> Rajasthan
>>>
>>>
>>>
>>>
>>> On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti 
>>> wrote:
>>>
>>>> create a tournament tree.in each round one value is eliminated to
>>>> obtain in the process the winner or the highest value in n-1 comparisons.
>>>> Then check the queue of the winner which contains log(n) entries of the
>>>> values beaten by the winner which implicitly will contain the runners
>>>> up.Then log(n)-1 comparisons to find the highest among all the losers whom
>>>> the winner had beaten. So all over complexity will be n-1 +log(n) -1 =
>>>> n+log(n)-2. Hp that answers ur query. nice question btw :)
>>>>
>>>>
>>>> On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI  wrote:
>>>>
>>>>> hey i'm also thinking n + logn -2.. but couldnt able to figure out
>>>>> how??? can you please explain the logic
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>>
>>>>  --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-18 Thread Ashima .
@malay: how cm n+logn-2?
cn u explain the logic ?
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sun, Sep 18, 2011 at 11:07 AM, Ashima .  wrote:

> rite! 62.5%
>
> Ashima
> M.Sc.(Tech)Information Systems
> 4th year
> BITS Pilani
> Rajasthan
>
>
>
>
> On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti wrote:
>
>> create a tournament tree.in each round one value is eliminated to obtain
>> in the process the winner or the highest value in n-1 comparisons. Then
>> check the queue of the winner which contains log(n) entries of the values
>> beaten by the winner which implicitly will contain the runners up.Then
>> log(n)-1 comparisons to find the highest among all the losers whom the
>> winner had beaten. So all over complexity will be n-1 +log(n) -1 =
>> n+log(n)-2. Hp that answers ur query. nice question btw :)
>>
>>
>> On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI  wrote:
>>
>>> hey i'm also thinking n + logn -2.. but couldnt able to figure out
>>> how??? can you please explain the logic
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-18 Thread Ashima .
rite! 62.5%
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sat, Sep 17, 2011 at 9:04 PM, malay chakrabarti wrote:

> create a tournament tree.in each round one value is eliminated to obtain
> in the process the winner or the highest value in n-1 comparisons. Then
> check the queue of the winner which contains log(n) entries of the values
> beaten by the winner which implicitly will contain the runners up.Then
> log(n)-1 comparisons to find the highest among all the losers whom the
> winner had beaten. So all over complexity will be n-1 +log(n) -1 =
> n+log(n)-2. Hp that answers ur query. nice question btw :)
>
>
> On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI  wrote:
>
>> hey i'm also thinking n + logn -2.. but couldnt able to figure out
>> how??? can you please explain the logic
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Ashima .
ans 8:
it should be 40%
@dheeraj: if total is 100 percent and other person paid more than 1st
person.Than how can the 1st person's percentage be more than 50%?
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sat, Sep 17, 2011 at 4:20 AM, Yogesh Yadav  wrote:

> Ans 1. apply bubble sort. outer loop should run just two times because in
> 2nd time the 2nd largest element will be at 2nd last position...
> comparisons=(n-1)+(n-2)
>
> On Sat, Sep 17, 2011 at 4:27 PM, Ashima .  wrote:
>
>> ans 2:
>> http://www.qbyte.org/puzzles/p131s.html
>>
>> Ashima
>> M.Sc.(Tech)Information Systems
>> 4th year
>> BITS Pilani
>> Rajasthan
>>
>>
>>
>>
>> On Sat, Sep 17, 2011 at 1:46 AM, Ashima .  wrote:
>>
>>> ans1: i think 2n but may be better solution is posible
>>> Ashima
>>> M.Sc.(Tech)Information Systems
>>>  4th year
>>> BITS Pilani
>>> Rajasthan
>>>
>>>
>>>
>>>
>>> On Fri, Sep 16, 2011 at 11:19 PM, Dheeraj Sharma <
>>> dheerajsharma1...@gmail.com> wrote:
>>>
>>>> ans 7. - 15 km east and 12 km south of origin
>>>>
>>>>
>>>> On Sat, Sep 17, 2011 at 11:29 AM, Dheeraj Sharma <
>>>> dheerajsharma1...@gmail.com> wrote:
>>>>
>>>>> Ans 8.   62.5 % ???
>>>>>
>>>>>
>>>>> On Sat, Sep 17, 2011 at 9:11 AM, VIHARRI wrote:
>>>>>
>>>>>> 1. Minimum no.of comparisons required to select the 2nd max element in
>>>>>> an array of N numbers.
>>>>>>
>>>>>> 2. What are the number of counting ties for four horses. ( example for
>>>>>> two horses A and B there are three cases - A wins, B wins, A & B
>>>>>> ties ).
>>>>>>
>>>>>> 3. What are the minimum no.of tournaments needed to get the winner. A
>>>>>> player is out when he loses two matches. Total players are 51.
>>>>>> ( Badminton ).
>>>>>>
>>>>>> 4. while(true)
>>>>>>{
>>>>>> sleep 1sencond;
>>>>>> if( getpid() % 2 == 0 )
>>>>>> {
>>>>>> fork();
>>>>>> }
>>>>>>   }
>>>>>> How many no.of processes are created by the end of 12th second, if
>>>>>> time starts from 0th second? Process id's start from 0.
>>>>>>
>>>>>> 5. Which of the following are thread safe?
>>>>>> a) Atomic operations
>>>>>> b) Mutual exclusion
>>>>>> c) Re-entrant
>>>>>> d) Queuing
>>>>>>
>>>>>> 6. When a dice is rolled the outcome of the face is summed up each
>>>>>> time, and rolling is stopped when the sum becomes greater than 100.
>>>>>> Which of the following have more probability to become sum.
>>>>>> a) 103
>>>>>> b) 102
>>>>>> c) 100
>>>>>> d) all have equal probability
>>>>>> e) 101
>>>>>>
>>>>>> 7. A man moves 1km east, 2km north, 3km west, 4km south, 5km east, 6km
>>>>>> north, 7km west and so on until he travels total of 300km so what
>>>>>> will be the distance from origin?
>>>>>>
>>>>>> 8. Alam bought 5pens, 7 pencils, 4 erasers. Ashok bought 6 pens, 8
>>>>>> erasers, 14 pencils and paid half more the amount Alam paid. What is
>>>>>> the percentage of amount did Alam spent on buying pens?
>>>>>>
>>>>>> 9. Time complexity to get min elements from MAX heap.
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "Algorithm Geeks" group.
>>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>>> To unsubscribe from this group, send email to
>>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> *Dheeraj Sharma*
>>>>> Comp Engg.
>>>>> NIT Kuru

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Ashima .
ans7:
my answer is coming to be as 12km west and 12 km south
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sat, Sep 17, 2011 at 3:57 AM, Ashima .  wrote:

> ans 2:
> http://www.qbyte.org/puzzles/p131s.html
>
> Ashima
> M.Sc.(Tech)Information Systems
> 4th year
> BITS Pilani
> Rajasthan
>
>
>
>
> On Sat, Sep 17, 2011 at 1:46 AM, Ashima .  wrote:
>
>> ans1: i think 2n but may be better solution is posible
>> Ashima
>> M.Sc.(Tech)Information Systems
>>  4th year
>> BITS Pilani
>> Rajasthan
>>
>>
>>
>>
>> On Fri, Sep 16, 2011 at 11:19 PM, Dheeraj Sharma <
>> dheerajsharma1...@gmail.com> wrote:
>>
>>> ans 7. - 15 km east and 12 km south of origin
>>>
>>>
>>> On Sat, Sep 17, 2011 at 11:29 AM, Dheeraj Sharma <
>>> dheerajsharma1...@gmail.com> wrote:
>>>
>>>> Ans 8.   62.5 % ???
>>>>
>>>>
>>>> On Sat, Sep 17, 2011 at 9:11 AM, VIHARRI  wrote:
>>>>
>>>>> 1. Minimum no.of comparisons required to select the 2nd max element in
>>>>> an array of N numbers.
>>>>>
>>>>> 2. What are the number of counting ties for four horses. ( example for
>>>>> two horses A and B there are three cases - A wins, B wins, A & B
>>>>> ties ).
>>>>>
>>>>> 3. What are the minimum no.of tournaments needed to get the winner. A
>>>>> player is out when he loses two matches. Total players are 51.
>>>>> ( Badminton ).
>>>>>
>>>>> 4. while(true)
>>>>>{
>>>>> sleep 1sencond;
>>>>> if( getpid() % 2 == 0 )
>>>>> {
>>>>> fork();
>>>>> }
>>>>>   }
>>>>> How many no.of processes are created by the end of 12th second, if
>>>>> time starts from 0th second? Process id's start from 0.
>>>>>
>>>>> 5. Which of the following are thread safe?
>>>>> a) Atomic operations
>>>>> b) Mutual exclusion
>>>>> c) Re-entrant
>>>>> d) Queuing
>>>>>
>>>>> 6. When a dice is rolled the outcome of the face is summed up each
>>>>> time, and rolling is stopped when the sum becomes greater than 100.
>>>>> Which of the following have more probability to become sum.
>>>>> a) 103
>>>>> b) 102
>>>>> c) 100
>>>>> d) all have equal probability
>>>>> e) 101
>>>>>
>>>>> 7. A man moves 1km east, 2km north, 3km west, 4km south, 5km east, 6km
>>>>> north, 7km west and so on until he travels total of 300km so what
>>>>> will be the distance from origin?
>>>>>
>>>>> 8. Alam bought 5pens, 7 pencils, 4 erasers. Ashok bought 6 pens, 8
>>>>> erasers, 14 pencils and paid half more the amount Alam paid. What is
>>>>> the percentage of amount did Alam spent on buying pens?
>>>>>
>>>>> 9. Time complexity to get min elements from MAX heap.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> *Dheeraj Sharma*
>>>> Comp Engg.
>>>> NIT Kurukshetra
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> *Dheeraj Sharma*
>>> Comp Engg.
>>> NIT Kurukshetra
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Ashima .
ans 2:
http://www.qbyte.org/puzzles/p131s.html
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Sat, Sep 17, 2011 at 1:46 AM, Ashima .  wrote:

> ans1: i think 2n but may be better solution is posible
> Ashima
> M.Sc.(Tech)Information Systems
>  4th year
> BITS Pilani
> Rajasthan
>
>
>
>
> On Fri, Sep 16, 2011 at 11:19 PM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> ans 7. - 15 km east and 12 km south of origin
>>
>>
>> On Sat, Sep 17, 2011 at 11:29 AM, Dheeraj Sharma <
>> dheerajsharma1...@gmail.com> wrote:
>>
>>> Ans 8.   62.5 % ???
>>>
>>>
>>> On Sat, Sep 17, 2011 at 9:11 AM, VIHARRI  wrote:
>>>
>>>> 1. Minimum no.of comparisons required to select the 2nd max element in
>>>> an array of N numbers.
>>>>
>>>> 2. What are the number of counting ties for four horses. ( example for
>>>> two horses A and B there are three cases - A wins, B wins, A & B
>>>> ties ).
>>>>
>>>> 3. What are the minimum no.of tournaments needed to get the winner. A
>>>> player is out when he loses two matches. Total players are 51.
>>>> ( Badminton ).
>>>>
>>>> 4. while(true)
>>>>{
>>>> sleep 1sencond;
>>>> if( getpid() % 2 == 0 )
>>>> {
>>>> fork();
>>>> }
>>>>   }
>>>> How many no.of processes are created by the end of 12th second, if
>>>> time starts from 0th second? Process id's start from 0.
>>>>
>>>> 5. Which of the following are thread safe?
>>>> a) Atomic operations
>>>> b) Mutual exclusion
>>>> c) Re-entrant
>>>> d) Queuing
>>>>
>>>> 6. When a dice is rolled the outcome of the face is summed up each
>>>> time, and rolling is stopped when the sum becomes greater than 100.
>>>> Which of the following have more probability to become sum.
>>>> a) 103
>>>> b) 102
>>>> c) 100
>>>> d) all have equal probability
>>>> e) 101
>>>>
>>>> 7. A man moves 1km east, 2km north, 3km west, 4km south, 5km east, 6km
>>>> north, 7km west and so on until he travels total of 300km so what
>>>> will be the distance from origin?
>>>>
>>>> 8. Alam bought 5pens, 7 pencils, 4 erasers. Ashok bought 6 pens, 8
>>>> erasers, 14 pencils and paid half more the amount Alam paid. What is
>>>> the percentage of amount did Alam spent on buying pens?
>>>>
>>>> 9. Time complexity to get min elements from MAX heap.
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>>
>>>
>>>
>>> --
>>> *Dheeraj Sharma*
>>> Comp Engg.
>>> NIT Kurukshetra
>>>
>>>
>>>
>>
>>
>> --
>> *Dheeraj Sharma*
>> Comp Engg.
>> NIT Kurukshetra
>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Ashima .
ans1: i think 2n but may be better solution is posible
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 16, 2011 at 11:19 PM, Dheeraj Sharma <
dheerajsharma1...@gmail.com> wrote:

> ans 7. - 15 km east and 12 km south of origin
>
>
> On Sat, Sep 17, 2011 at 11:29 AM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> Ans 8.   62.5 % ???
>>
>>
>> On Sat, Sep 17, 2011 at 9:11 AM, VIHARRI  wrote:
>>
>>> 1. Minimum no.of comparisons required to select the 2nd max element in
>>> an array of N numbers.
>>>
>>> 2. What are the number of counting ties for four horses. ( example for
>>> two horses A and B there are three cases - A wins, B wins, A & B
>>> ties ).
>>>
>>> 3. What are the minimum no.of tournaments needed to get the winner. A
>>> player is out when he loses two matches. Total players are 51.
>>> ( Badminton ).
>>>
>>> 4. while(true)
>>>{
>>> sleep 1sencond;
>>> if( getpid() % 2 == 0 )
>>> {
>>> fork();
>>> }
>>>   }
>>> How many no.of processes are created by the end of 12th second, if
>>> time starts from 0th second? Process id's start from 0.
>>>
>>> 5. Which of the following are thread safe?
>>> a) Atomic operations
>>> b) Mutual exclusion
>>> c) Re-entrant
>>> d) Queuing
>>>
>>> 6. When a dice is rolled the outcome of the face is summed up each
>>> time, and rolling is stopped when the sum becomes greater than 100.
>>> Which of the following have more probability to become sum.
>>> a) 103
>>> b) 102
>>> c) 100
>>> d) all have equal probability
>>> e) 101
>>>
>>> 7. A man moves 1km east, 2km north, 3km west, 4km south, 5km east, 6km
>>> north, 7km west and so on until he travels total of 300km so what
>>> will be the distance from origin?
>>>
>>> 8. Alam bought 5pens, 7 pencils, 4 erasers. Ashok bought 6 pens, 8
>>> erasers, 14 pencils and paid half more the amount Alam paid. What is
>>> the percentage of amount did Alam spent on buying pens?
>>>
>>> 9. Time complexity to get min elements from MAX heap.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>
>>
>> --
>> *Dheeraj Sharma*
>> Comp Engg.
>> NIT Kurukshetra
>>
>>
>>
>
>
> --
> *Dheeraj Sharma*
> Comp Engg.
> NIT Kurukshetra
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Plz explain the output..........

2011-09-17 Thread Ashima .
@yogesh : but if  in place of x=1 in above code, I write t=54. that means i
m assigning somevalue to a float variable.Then it should print 54
afterwards.
but its again printing 98. how does it go with ur concept.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 16, 2011 at 11:46 PM, abhinav gupta wrote:

> @yogesh :ya u right.
>
>
> On Sat, Sep 17, 2011 at 11:58 AM, sukran dhawan wrote:
>
>> x== 9 is not an error !!! it simply returns a non zero value if its true
>> and 0 if its false
>>
>> On Sat, Sep 17, 2011 at 11:39 AM, praveen raj wrote:
>>
>>> This will show syntax error due to x==9 and otherwise since memory
>>> address given at the declarAtion there fore  x value will. Change at every
>>> assignment , but i m not sure printf will give an error or not . Plz reply.
>>>
>>> On 17-Sep-2011 1:13 AM, "Anshul AGARWAL" 
>>> wrote:
>>> >
>>> > #include
>>> > int  main()
>>> > {float t;
>>> > long x;
>>> >
>>> >
>>> > t=98;
>>> > printf("%d\n",t);
>>> >   printf("%f\n",x);
>>> > {
>>> > x=1;
>>> > printf("%f\n",x);
>>> > {
>>> >
>>> > x=30;
>>> > printf("%f\n",x);
>>> > }
>>> > printf("%f\n",x);
>>> > }
>>> > x==9;
>>> > printf("%f\n",x);
>>> >
>>> > }
>>> > 
>>> > ---
>>> > Anshul Agarwal
>>> > Nit Allahabad
>>> > Computer Science
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Math Puzzle

2011-09-15 Thread Ashima .
solution is =3 with the condition p!=0 and q!=0 and r!=0
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Thu, Sep 15, 2011 at 10:38 PM, Piyush Grover
wrote:

> @abhinav...
>
> it's not about being over smart or to show someone or to prove someone
> anything. It's just that
> you should not take any assumptions by yourself or if you do you should
> specify clearly.
> If u r asked this question in an interview and you give the answer 3
> without telling your assumption, u r done!!
>
> And if you are living in the programming world, you need to take care of
> all the possible scenarios otherwise u will end up throwing exceptions and
> segmentation faults.
>
>
>
> On Thu, Sep 15, 2011 at 10:32 PM, Don  wrote:
>
>> Right, and in every proof above, at some point there is a possible
>> division by zero. Therefore the proof is not valid in cases where R or
>> P or Q are zero, and there are infinitely many such cases.
>> The problem states P+Q+R=0 as the only constraint. There are
>> infinitely many cases which fit that constraint where the expression
>> is not equal to 3.
>> Don
>>
>> On Sep 15, 11:57 am, abhinav gupta  wrote:
>> > u cnt divide a number by 0..that thing is self undrstod
>> >
>> > On Thu, Sep 15, 2011 at 9:49 AM, Piyush Grover <
>> piyush4u.iit...@gmail.com>wrote:
>> >
>> >
>> >
>> > > Don is right
>> >
>> > > if R = 0, P = 1 and Q = -1 then the given expression is UNDEFINED!!!
>> >
>> > > On Thu, Sep 15, 2011 at 10:16 PM, abhinav gupta <
>> guptaabhinav...@gmail.com
>> > > > wrote:
>> >
>> > >> Shut up...its 3,,
>> >
>> > >> On Thu, Sep 15, 2011 at 9:43 AM, Don  wrote:
>> >
>> > >>> It might be 3, but it doesn't have to be 3.
>> > >>> Don
>> >
>> > >>> On Sep 14, 11:56 pm, NAGARAJAN SIVARAMAN 
>> wrote:
>> > >>> > if P+Q+R= 0  then P2 /QR  + Q2/PR + R2/PQ = ??
>> >
>> > >>> > how to solve this??
>> >
>> > >>> --
>> > >>> You received this message because you are subscribed to the Google
>> Groups
>> > >>> "Algorithm Geeks" group.
>> > >>> To post to this group, send email to algogeeks@googlegroups.com.
>> > >>> To unsubscribe from this group, send email to
>> > >>> algogeeks+unsubscr...@googlegroups.com.
>> > >>> For more options, visit this group at
>> > >>>http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > >> --
>> > >> @ |3  # ! /\/ @ \./
>> >
>> > >>  --
>> > >> You received this message because you are subscribed to the Google
>> Groups
>> > >> "Algorithm Geeks" group.
>> > >> To post to this group, send email to algogeeks@googlegroups.com.
>> > >> To unsubscribe from this group, send email to
>> > >> algogeeks+unsubscr...@googlegroups.com.
>> > >> For more options, visit this group at
>> > >>http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > >  --
>> > > You received this message because you are subscribed to the Google
>> Groups
>> > > "Algorithm Geeks" group.
>> > > To post to this group, send email to algogeeks@googlegroups.com.
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscr...@googlegroups.com.
>> > > For more options, visit this group at
>> > >http://groups.google.com/group/algogeeks?hl=en.
>> >
>> > --
>> > @ |3  # ! /\/ @ \./
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Please provide Code to Find kth Smallest or kth Largest element in unsorted array in liner time ?

2011-09-05 Thread Ashima .
@dave:what if u have duplicate elements
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Mon, Sep 5, 2011 at 7:11 PM, Dave  wrote:

> @Sachin: Correct: in one quicksort pivoting pass, the array is
> rearranged so that the pivot element is put in the correct spot, with
> larger elements on the right and smaller ones on the left. Now, if the
> pivot, a[p], is at location k, i.e. p = k, then you are done. If not,
> do another quicksort on the correct side of p; i.e., either on a[0] to
> a[p-1] or on a[p+1] to a[n-1], depending on whether k is less than p
> or greater than p.
>
> Dave
>
> On Sep 5, 1:27 am, sachin goyal  wrote:
> > PLEASE TELL ME HOW WE CAN USE QUICK SORT TO FIND THE ELEMENT
> > BECAUSE IN QUICK SORT ONE ELEMENT IN SHIFT IN ITS RIGHT POSITION ALL
> LEFTS
> > ARE SMALLER AND ALL RIGHT ARE BIG
> >
> > On Mon, Sep 5, 2011 at  POSIT11:55 AM, sachin goyal
> > wrote:
> >
> >
> >
> > > PLEASE TELL HOW
> >
> > > On Sun, Sep 4, 2011 at 7:23 PM, sarath prasath <
> prasathsar...@gmail.com>wrote:
> >
> > >> another sol which i learned from my friend is
> > >> think of heap sort...
> >
> > >> On Sun, Sep 4, 2011 at 6:28 PM, learner 
> wrote:
> >
> > >>> something I Know using quick sort randomization function we can find
> > >>> kt smallest/largest in unsorted array , but i am not able to write
> > >>> code , please help me in this and provide the code for the same.?
> >
> > >>> Thanks
> > >>> Nimish K.
> > >>> 1st Year
> > >>> IITR
> >
> > >>> --
> > >>> You received this message because you are subscribed to the Google
> Groups
> > >>> "Algorithm Geeks" group.
> > >>> To post to this group, send email to algogeeks@googlegroups.com.
> > >>> To unsubscribe from this group, send email to
> > >>> algogeeks+unsubscr...@googlegroups.com.
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/algogeeks?hl=en.
> >
> > >>  --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Algorithm Geeks" group.
> > >> To post to this group, send email to algogeeks@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> algogeeks+unsubscr...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: subarray wid sum=k

2011-09-02 Thread Ashima .
Logic: since n numbers are there,so there can be (2^n)-1 cases.Just as for n
bits we have 2^n possible combinations.
Keeping above logic in mind,We can also create a binary tree with root node
as 0.From there create 2 child nodes:1)number 2) 0. 1st child node indicates
that number was taken in subset and 2nd child node indicates that number was
not taken.similarly make a tree with all such possible combinations.
FInd sum corresponding to all the the paths.
If that sum =k(given) then it means subset exists.Else not.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Sep 2, 2011 at 5:26 AM, manish kapur wrote:

> @bharatkumar..cn u pls share the algo
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: microsoft interview

2011-08-31 Thread Ashima .
@dave wats d logic behind ur code

Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Wed, Aug 31, 2011 at 9:05 AM, Dave  wrote:

> @Manish:
>
> for( i = 1 ; i < n ; ++i )
>for( j = 1 ; j < m ; ++j )
>if( a[i][j] != 0 )
>a[i][0] = a[0][j] = 1;
> for( i = 1 ; i < n ; ++i )
>for( j = 1 ; j < m ; ++j )
>if( a[i][0] + a[0][j] != 0 )
>a[i][j] = 1;
>
> Dave
>
> On Aug 31, 8:40 am, manish kapur  wrote:
> > Input is a matrix of size n x m of 0s and 1s.
> >
> > eg:
> > 1 0 0 1
> > 0 0 1 0
> > 0 0 0 0
> >
> > If a location has 1; make all the elements of that row and column = 1. eg
> >
> > 1 1 1 1
> > 1 1 1 1
> > 1 0 1 1
> >
> > Solution should be with Time complexity = O(n*m) and O(1) extra space
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what is the error???

2011-08-31 Thread Ashima .
u hv just declared the variable and not defined it.So no memory is allocated
to var. so u l get the undefined reference error.
either remove extern or define new local variable int var =10;
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Wed, Aug 31, 2011 at 7:56 AM, Rajesh Kumar wrote:

> What we do to remove error??
>  #include
> extern int var;
> main()
> {
>  var=10;
>  return 0;
> }
>
> Regards
> Rajesh Kumar
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] amazon

2011-08-22 Thread Ashima .
can anyone explain wy these 2 will be different ,atleast wen they are
passed as actual or formal parameters.
As in case of actual parameters, both will be passed as "n"--> some address
value.
In  case of formal parameters,char n[]  takes the form of char*n. So where
is the difference highlighted in both the cases.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Mon, Aug 22, 2011 at 9:34 PM, sukran dhawan wrote:

> take the size of char * p and char p [] to confirm the same
>
>
> On Mon, Aug 22, 2011 at 9:32 PM, Anand Prasad wrote:
>
>> yea,, true.. spot on actually..
>> Anand
>>
>>
>>
>> On Mon, Aug 22, 2011 at 9:30 PM, sukran dhawan wrote:
>>
>>> they are different !!! char p[] is a constant pointer and char * p is
>>> not.
>>> u can do something like this
>>>
>>> char * p;
>>> p="dgdfg";
>>>
>>> but not the same for char p[]
>>>
>>> On Mon, Aug 22, 2011 at 8:55 PM, priya ramesh <
>>> love.for.programm...@gmail.com> wrote:
>>>
>>>> The compiler will distinguish between char n[] and char * in which part
>>>> of the prog??
>>>> 1. In actual parameters of function arguments
>>>> 2. In formal parameters of function arguments
>>>> 3. in both
>>>>
>>>> generally after 1st online technical round what is the cut off for
>>>> amazon??
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Amazon Ques

2011-08-22 Thread Ashima .
Since its not a Linked list,
so get middle value from "top"
pop till middle element and push elements in a new stack.
again push the elemetns back to original stack,except for the middle
element.
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Mon, Aug 22, 2011 at 8:49 PM, *$*  wrote:

> Hi,
>  How about the following approach.
>
> lets take stack is stack1.
> lets take 2 pointers , p1 and p2
> for every pop , keep increment p1 , so that p1 will point to latest pop'ed
> out element.
> increment p2 for every odd count of pop's...
>
> increment p2 , for 1 , 3 , 5 , pop'ings etc..
> so at the end , p2 will point to middle element of the stack.
>
>
> Thx,
> --Gopi
>
>
> On Mon, Aug 22, 2011 at 8:04 PM, muthu raj  wrote:
>
>> Sorry i dint read the question properly :)
>>
>> *Muthuraj R
>> IV th Year , ISE
>> PESIT , Bangalore*
>>
>>
>>
>> On Mon, Aug 22, 2011 at 7:24 AM, sukran dhawan wrote:
>>
>>> count is required since its not implemented as LL
>>>
>>>
>>> On Mon, Aug 22, 2011 at 7:47 PM, shady  wrote:
>>>
>>>> i wish u had read the question... it is simple.. push to new stack and
>>>> then pop back... number of elements count need to be there
>>>>
>>>>
>>>> On Mon, Aug 22, 2011 at 7:44 PM, muthu raj wrote:
>>>>
>>>>> No need to count the number of nodes. Since its implemented as a linked
>>>>> list traverse the list with two two pointers one incremented one node next
>>>>> and other incremented two nodes next simultaneously.
>>>>>
>>>>> void delete_MiddleStack(node **h)
>>>>> {
>>>>>
>>>>>  if(*h==NULL)
>>>>>  return;
>>>>>  node *p,*q;
>>>>> p=*h;
>>>>>   q=*h;
>>>>>  while(q->next!=NULL)
>>>>> {
>>>>> p=p->next;
>>>>> if(q->next==NULL)
>>>>> q=q->next;
>>>>>   else q=q->next->next;
>>>>> }
>>>>> p->ele=p->next->ele;
>>>>> q=p->next;
>>>>> p->next=p->next->next;
>>>>> free(q);
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> *Muthuraj R
>>>>> IV th Year , ISE
>>>>> PESIT , Bangalore*
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Mon, Aug 22, 2011 at 5:08 AM, vikas wrote:
>>>>>
>>>>>> why to bother this much...? just count the elements when popping and
>>>>>> output the middle one .
>>>>>> while(!s.empty()){
>>>>>> e= s.pop()
>>>>>> count++
>>>>>> q.enq(e);
>>>>>> }
>>>>>>
>>>>>> count <<= 2;
>>>>>>
>>>>>> while(count){
>>>>>> e = q.deq();
>>>>>> s.push(e);
>>>>>> count --;
>>>>>> }
>>>>>> output s.top()
>>>>>>
>>>>>> while(!q.empty()){
>>>>>> e = q.deq();
>>>>>> s.push(e);
>>>>>> }
>>>>>>
>>>>>>
>>>>>> On Aug 22, 4:27 pm, Shravan Kumar  wrote:
>>>>>> > Pop each element and en-queue it twice and de-queue it once. When
>>>>>> stack is
>>>>>> > empty the front of the queue will be middle element.
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > On Mon, Aug 22, 2011 at 4:01 PM, Ankur Garg 
>>>>>> wrote:
>>>>>> > > Find the middle of the stack..(Time complexity should be minimum)
>>>>>> >
>>>>>> > > Stack is not implemented as Linked List ...u have normal stack
>>>>>> with
>>>>>> > > push,pop and top
>>>>>> >
>>>>>> > > How to do this ??
>>>>>> >
>>>>>> > > --
>>>>>> > > You received this message because you are subscribed to the Google
>>>>>> Gro

Re: [algogeeks] how to find median of two sorted arrays

2011-08-18 Thread Ashima .
@Arjoo kumar value of loops will vary acc to sum is odd or even
loops = sum/2 (sum even)
=(sum/2) + 1 (sum odd)
Ashima
M.Sc.(Tech)Information Systems
4th year
BITS Pilani
Rajasthan




On Fri, Aug 19, 2011 at 11:10 AM, Sanjay Rajpal wrote:

> Plz make one point clear can we use extra space or not ?
>
> because complexity will vary depending upon the approach.
>
> *Regards
>
> Sanju
>
> Happy to Help :)*
>
>
>
>
> On Fri, Aug 19, 2011 at 11:04 AM, arjoo kumar <2009ar...@gmail.com> wrote:
>
>> find
>> 1length1 (arr1)
>> 2length 2(arr2)
>> 3sum = length1 +length 2
>> 4loops = sum /2
>> 5... set two pointer (say ptr1 & ptr2) on arr[0]& arr2[0]
>> 6 start loop for i =1 to loops
>>   if (*ptr1 <= *ptr2 )
>>ptr1++
>>   else
>>ptr2++
>>
>> please manage it & remaining part send after some time
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.