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

2011-09-16 Thread abhinav gupta
@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.



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

2011-09-16 Thread sukran dhawan
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.



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

2011-09-16 Thread Yogesh Yadav
x==9 is not an error...

it will be 1 when true and 0 when false...and both are executable
statements...

when we print float with %d then compiler prints 0...and when we print
integer with %f then compiler prints last assigned or printed float value to
any float variablehere it is assigned for t.. so it will print t again
and again

...
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.



Re: [algogeeks] Directi Questions - needed answers

2011-09-16 Thread Dheeraj Sharma
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.



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

2011-09-16 Thread praveen raj
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.



Re: [algogeeks] Directi Questions - needed answers

2011-09-16 Thread Dheeraj Sharma
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

-- 
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-16 Thread sukran dhawan
Printing a floating point with  %d conversion specifier will not print the
expected resultss !

On Sat, Sep 17, 2011 at 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.



Re: [algogeeks] Re: algorithm problem

2011-09-16 Thread surender sanke
@ankur,
does this actually connects from start station to end station??
i think ur solution creates path which could be discontinuous,
but we want end to end connected path
surender
On Sat, Sep 17, 2011 at 5:39 AM, Ankur Garg  wrote:

> Some typos in my solution  :(
> Use a Max heap..
>
> first take the first 10 stations and build a* Max *heap O(10)..Heap
> contains distance between 2 stations  . Initial Heap will contain 10 *minimum
> *distances with maximum of those  at the top . Now 11 th comes u compare
> with the root of the heap . If its less than that than replace it with the
> top and run heapify (O(log10) ) ..keep doing the same . In the end u have 10
> stations with min distance between them
>
> Complexity O(10) + O(log(10)) = O(1) ..Comparision takes constant time
>
> So total complexity O(1)
>
> Regards
> Ankur
>
> On Sat, Sep 17, 2011 at 5:00 AM, Dave  wrote:
>
>> @Pankaj: Let's number the stations from 0 to 101, where stations 0 and
>> 101 are the end stations and stations 1 through 100 are the
>> intermediate stations. Let a[i], i = 1, 2, ..., 100 be the distance of
>> station i from station 0, and finally assume that the a's are
>> increasing, i.e., that the stations are presented in order. We want to
>> find i[1], i[2], ..., i[10] such that 0 = i[0] < i[1] < i[2] < ... <
>> i[10] < i[11] <= 101. Given any x, 0 < x <= a[101] (the distance
>> between the end stations), we can find the last station that is within
>> x of station 0. Call this station i1. In other words, a[i1] <= x but
>> a[i1+1] > x. Now find the last station that is within x of station
>> i[1] and call it i[2]. Etc until you find the last station that is
>> within x of station i10. If you get to station 101 in the process, the
>> rest of the i's = 101. This can be done with a linear search in
>> O(100), or using 10 binary searches in O(10 log 100). Now the problem
>> is to find the smallest x such that I[11] = 101. We can do this with a
>> binary search on x. Initialize xmin = a[101]/11 (that would have the
>> 10 intermediate stations equally spaced) and xmax = a[101] and begin a
>> loop. Let x = xmin + (xmax - xmin)/2. If x == xmin or x == xmax,
>> break; xmax is the minimax distance between stations and i[1], ...,
>> i[10] are the stations. Otherwise, calculate i[1] through i[11] as
>> above. If i[11] < 101, then x is too small, so set xmin = x and loop.
>> If i[11] = 101, then x is too large, so set xmax = x and loop.
>>
>> Dave
>>
>> On Sep 16, 1:22 pm, pankaj kumar  wrote:
>> > You are given two end points ( consider them as two end stations
>> > at some distance  ) there are 100 stations between these two . Now you
>> > need to build a train track between these two end points which
>> > includes only 10 stations and not more than that . Now the objective
>> > is to find such 10 stations such that the maximum distance between any
>> > two consecutive stations is minimum .
>> >
>> > mine solution is
>> >
>> >  find all  possible subset of 10 elements and answer is that subset
>> > for which sum (of distance  between
>> > consecutive stations )is minimum..
>> > is it correct or any other solution.
>>
>> --
>> 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.



[algogeeks] Directi Questions - needed answers

2011-09-16 Thread VIHARRI
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.



Re: [algogeeks] Microsoft Question

2011-09-16 Thread Anup Ghatage
As WgpShashank once pointed out.

Search the whole matrix for the first character instances, for each
instance, send the array, string and that char's position to a function that
will recursively check its direct neighbors for the next character.
Exhaustively check like that for each starting characters appearance till
you find the string, if any.

On Fri, Sep 16, 2011 at 11:55 PM, Ankur Garg  wrote:

> In a matrix of characters, find an string. String can be in any way (all 8
> neighbours to be considered)
> like find Microsoft in below matrix.
>
>  A
> C
> P
> *R
> *C*
> *X
> *S
> **O
> *P
> *C*
> V
> *O*
> V
> N
> *I*
> W
> G
> *F
> **M
> *N
> Q
> A
> *T*
> I
> T
>
> *Any Ideas How to Solve/Approach this problem ?*
>
>
>  --
> 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.
>



-- 
Anup Ghatage

-- 
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.



[algogeeks] Re: royal bank of scotland

2011-09-16 Thread gaurav bansal
is GD a part of a selection process or only personal interviews are
taken after shortlisting

On Sep 16, 10:30 pm, rahul sharma  wrote:
> i was teellling about placement procedure
>
> On Fri, Sep 16, 2011 at 9:12 PM, Rahul Verma wrote:
>
>
>
>
>
>
>
> > Opportunities for the experienced candidates.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/algogeeks/-/y6n4Hd9fqTQJ.
>
> > 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.



[algogeeks] Can anyone tell amazon written questions ??? thanx in adv.

2011-09-16 Thread Deoki Nandan
-- 
**With Regards
Deoki Nandan Vishwakarma

*
*

-- 
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: algorithm problem

2011-09-16 Thread Ankur Garg
Some typos in my solution  :(
Use a Max heap..

first take the first 10 stations and build a* Max *heap O(10)..Heap contains
distance between 2 stations  . Initial Heap will contain 10 *minimum
*distances
with maximum of those  at the top . Now 11 th comes u compare with the root
of the heap . If its less than that than replace it with the top and run
heapify (O(log10) ) ..keep doing the same . In the end u have 10 stations
with min distance between them

Complexity O(10) + O(log(10)) = O(1) ..Comparision takes constant time

So total complexity O(1)

Regards
Ankur

On Sat, Sep 17, 2011 at 5:00 AM, Dave  wrote:

> @Pankaj: Let's number the stations from 0 to 101, where stations 0 and
> 101 are the end stations and stations 1 through 100 are the
> intermediate stations. Let a[i], i = 1, 2, ..., 100 be the distance of
> station i from station 0, and finally assume that the a's are
> increasing, i.e., that the stations are presented in order. We want to
> find i[1], i[2], ..., i[10] such that 0 = i[0] < i[1] < i[2] < ... <
> i[10] < i[11] <= 101. Given any x, 0 < x <= a[101] (the distance
> between the end stations), we can find the last station that is within
> x of station 0. Call this station i1. In other words, a[i1] <= x but
> a[i1+1] > x. Now find the last station that is within x of station
> i[1] and call it i[2]. Etc until you find the last station that is
> within x of station i10. If you get to station 101 in the process, the
> rest of the i's = 101. This can be done with a linear search in
> O(100), or using 10 binary searches in O(10 log 100). Now the problem
> is to find the smallest x such that I[11] = 101. We can do this with a
> binary search on x. Initialize xmin = a[101]/11 (that would have the
> 10 intermediate stations equally spaced) and xmax = a[101] and begin a
> loop. Let x = xmin + (xmax - xmin)/2. If x == xmin or x == xmax,
> break; xmax is the minimax distance between stations and i[1], ...,
> i[10] are the stations. Otherwise, calculate i[1] through i[11] as
> above. If i[11] < 101, then x is too small, so set xmin = x and loop.
> If i[11] = 101, then x is too large, so set xmax = x and loop.
>
> Dave
>
> On Sep 16, 1:22 pm, pankaj kumar  wrote:
> > You are given two end points ( consider them as two end stations
> > at some distance  ) there are 100 stations between these two . Now you
> > need to build a train track between these two end points which
> > includes only 10 stations and not more than that . Now the objective
> > is to find such 10 stations such that the maximum distance between any
> > two consecutive stations is minimum .
> >
> > mine solution is
> >
> >  find all  possible subset of 10 elements and answer is that subset
> > for which sum (of distance  between
> > consecutive stations )is minimum..
> > is it correct or any other solution.
>
> --
> 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.



[algogeeks] Re: algorithm problem

2011-09-16 Thread Dave
@Pankaj: Let's number the stations from 0 to 101, where stations 0 and
101 are the end stations and stations 1 through 100 are the
intermediate stations. Let a[i], i = 1, 2, ..., 100 be the distance of
station i from station 0, and finally assume that the a's are
increasing, i.e., that the stations are presented in order. We want to
find i[1], i[2], ..., i[10] such that 0 = i[0] < i[1] < i[2] < ... <
i[10] < i[11] <= 101. Given any x, 0 < x <= a[101] (the distance
between the end stations), we can find the last station that is within
x of station 0. Call this station i1. In other words, a[i1] <= x but
a[i1+1] > x. Now find the last station that is within x of station
i[1] and call it i[2]. Etc until you find the last station that is
within x of station i10. If you get to station 101 in the process, the
rest of the i's = 101. This can be done with a linear search in
O(100), or using 10 binary searches in O(10 log 100). Now the problem
is to find the smallest x such that I[11] = 101. We can do this with a
binary search on x. Initialize xmin = a[101]/11 (that would have the
10 intermediate stations equally spaced) and xmax = a[101] and begin a
loop. Let x = xmin + (xmax - xmin)/2. If x == xmin or x == xmax,
break; xmax is the minimax distance between stations and i[1], ...,
i[10] are the stations. Otherwise, calculate i[1] through i[11] as
above. If i[11] < 101, then x is too small, so set xmin = x and loop.
If i[11] = 101, then x is too large, so set xmax = x and loop.

Dave

On Sep 16, 1:22 pm, pankaj kumar  wrote:
> You are given two end points ( consider them as two end stations
> at some distance  ) there are 100 stations between these two . Now you
> need to build a train track between these two end points which
> includes only 10 stations and not more than that . Now the objective
> is to find such 10 stations such that the maximum distance between any
> two consecutive stations is minimum .
>
> mine solution is
>
>  find all  possible subset of 10 elements and answer is that subset
> for which sum (of distance  between
> consecutive stations )is minimum..
> is it correct or any other solution.

-- 
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: algorithm problem

2011-09-16 Thread Ankur Garg
Use a Max heap..

first take the first 10 stations and build a min heap O(10)..Heap contains
distance between 2 stations  . Initial Heap will contain 10 min distances
with highest at the top . Now 11 th comes u compare with the root of the
heap . If its less than that than replace it with the top and run heapify
(O(log10) ) ..keep doing the same . In the end u have 10 stations with min
distance between them

Complexity O(10) + O(log(10)) = O(1) ..Comparision takes constant time

So total complexity O(1)

Regards
Ankur

On Sat, Sep 17, 2011 at 2:16 AM, Gene  wrote:

> All possible subsets of 10 elements is B(100,10), which is over 17
> trillion. Not a great algorithm.
>
> You can do this by constructing sets S_0, S_1, S_2, ... S_10, S_11 of
> stations accessible from the start in 0,1,2,...10, 11 hops. The 11th
> is from the final station to the destination. It's simple to construct
> S_i+1 from S_i.  I'll leave it to you.  For each element of each S_i
> it's also straightforward to keep track of the min of the max distance
> that had to be traversed to get to there and a backward pointer to the
> previous station on the best path. (A bit of care is needed for the
> case where there's a cycle in the path.  In this case a city may have
> two or more predecessors!) After you've constructed S_11, look for the
> destination there.  If you find it, read off the path in reverse using
> the back pointers.  If it's not there, there exists no path of length
> 10.
>
> If this sounds like Dijkstra's shortest path to you, you're onto
> something.  It's pretty close except that the concrete length of 10
> simplifies things.
>
> If you are interested in paths with fewer than 10 stations, that's a
> simple modification I'll also leave to you.
>
> On Sep 16, 8:22 pm, pankaj kumar  wrote:
> > You are given two end points ( consider them as two end stations
> > at some distance  ) there are 100 stations between these two . Now you
> > need to build a train track between these two end points which
> > includes only 10 stations and not more than that . Now the objective
> > is to find such 10 stations such that the maximum distance between any
> > two consecutive stations is minimum .
> >
> > mine solution is
> >
> >  find all  possible subset of 10 elements and answer is that subset
> > for which sum (of distance  between
> > consecutive stations )is minimum..
> > is it correct or any other solution.
>
> --
> 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.



[algogeeks] Re: algorithm problem

2011-09-16 Thread Gene
All possible subsets of 10 elements is B(100,10), which is over 17
trillion. Not a great algorithm.

You can do this by constructing sets S_0, S_1, S_2, ... S_10, S_11 of
stations accessible from the start in 0,1,2,...10, 11 hops. The 11th
is from the final station to the destination. It's simple to construct
S_i+1 from S_i.  I'll leave it to you.  For each element of each S_i
it's also straightforward to keep track of the min of the max distance
that had to be traversed to get to there and a backward pointer to the
previous station on the best path. (A bit of care is needed for the
case where there's a cycle in the path.  In this case a city may have
two or more predecessors!) After you've constructed S_11, look for the
destination there.  If you find it, read off the path in reverse using
the back pointers.  If it's not there, there exists no path of length
10.

If this sounds like Dijkstra's shortest path to you, you're onto
something.  It's pretty close except that the concrete length of 10
simplifies things.

If you are interested in paths with fewer than 10 stations, that's a
simple modification I'll also leave to you.

On Sep 16, 8:22 pm, pankaj kumar  wrote:
> You are given two end points ( consider them as two end stations
> at some distance  ) there are 100 stations between these two . Now you
> need to build a train track between these two end points which
> includes only 10 stations and not more than that . Now the objective
> is to find such 10 stations such that the maximum distance between any
> two consecutive stations is minimum .
>
> mine solution is
>
>  find all  possible subset of 10 elements and answer is that subset
> for which sum (of distance  between
> consecutive stations )is minimum..
> is it correct or any other solution.

-- 
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.



[algogeeks] Re: An interesting question

2011-09-16 Thread SAMMM
You can try this also this will work in C++ not in C .

I ) For Register Variable :-

#include

int main()
{
register int c=100;
printf("%u ",&c);
return 0;
}




II ) Function inside a structure :-

#include

struct Test
{
  char c;
  void function()
  {
printf("hi\n");
  }
};

int main()
{
 struct Test t;
 t.function();
  return 0;
}


##



For the opposite Works in C not in C++:-

Compulsory to return an INT in CPP .

#include

main()
{
 int c=100;
 printf("%d \n",c);
 return ;
}

-- 
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: question on algorithm

2011-09-16 Thread prasanth n
@Don:
thanks a lot

On Sat, Sep 17, 2011 at 12:28 AM, Don  wrote:

> The algorithm is to count them, looping over the number of quarters
> and dimes. Then it is easy to compute the number of nickles which
> could be used, and the shortfall is made up with pennies.
> It is very common to see a recursive solution, but that is not
> necessary or beneficial when the iterative solution is so simple.
> Don
>
>  int result = 0;
>  for(int quarters = 0; quarters <= n; quarters += 25)
>  for(int dimes = 0; (quarters+dimes) <= n; dimes += 10)
>result += 1 + (n-quarters-dimes) / 5;
>
> On Sep 16, 1:35 pm, prasanth n  wrote:
> > Given an infinite number of quarters (25 cents), dimes (10 cents),
> nickels
> > (5 cents) and pennies (1 cent), write code to calculate the number of
> ways
> > of representing n cents.
> > also do give an algorithm first..
> >
> > --
> > *prasanth*
>
> --
> 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.
>
>


-- 
*prasanth*

-- 
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.



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

2011-09-16 Thread Anshul AGARWAL
#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.



[algogeeks] Re: question on algorithm

2011-09-16 Thread Don
The algorithm is to count them, looping over the number of quarters
and dimes. Then it is easy to compute the number of nickles which
could be used, and the shortfall is made up with pennies.
It is very common to see a recursive solution, but that is not
necessary or beneficial when the iterative solution is so simple.
Don

  int result = 0;
  for(int quarters = 0; quarters <= n; quarters += 25)
  for(int dimes = 0; (quarters+dimes) <= n; dimes += 10)
result += 1 + (n-quarters-dimes) / 5;

On Sep 16, 1:35 pm, prasanth n  wrote:
> Given an infinite number of quarters (25 cents), dimes (10 cents), nickels
> (5 cents) and pennies (1 cent), write code to calculate the number of ways
> of representing n cents.
> also do give an algorithm first..
>
> --
> *prasanth*

-- 
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.



[algogeeks] Re: Schneider electric !!

2011-09-16 Thread siva viknesh
is this company eligible for cse?? for what post?? package??

On Sep 14, 9:12 pm, jestincobol nair  wrote:
> Has anyone attended schneider electric placement ?? if yes plz share ur
> experience it is coming after 2 days to my coll.

-- 
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.



[algogeeks] Re: PLEASE HELP ME - Party Lamps

2011-09-16 Thread Don
There are a lot of simplifications you can make to get this problem
down to a manageable size.

First of all, notice that each of the four buttons inverts itsself. So
if you press it twice, you are back to the initial state. The order of
button pushes does not matter. Any order of the same button pushes
will result in the same set of lights being on. Thus you only need to
know if it was pushed an even number of times or an odd number of
times.

The value of C limits the options if it is less than 4. If C is 3,
then all four buttons could not have been pushed an odd number of
times. Either 1 or 3 of the buttons was pushed an odd number of times.
If C is odd, then an odd number of buttons were pushed an odd number
of times. If C is even, and even number of buttons were pushed an even
number of times.

Now here is the big one which really is not mentioned in the solution.
You only need to know the state of lamps 1-6. If you know the state of
lamp x, lamp x+6*y is the same. This is true because each button works
on an interval divisible by 6. Button 1 affects all lights, button 2
and 3 affect alternating lights, and button 3 affects every third
light. So if light 2 is on, so is light 8, 14, 20, etc. You just need
to try the 16 possible combinations of odd/even button pushes. At most
eight of them will be possible based on the value of C. Determine the
final state of lamps 1-6, and then determine if that is consistent
with the given final states. If so, output that result.

Don

On Sep 16, 12:05 pm, Blackwizard 
wrote:
> I've read this following solution from USACO for "IOI98 - Party Lamps"
> problem..but I don't know why 2^4 and I don't know why the complete
> search works for this problem...!!!
> I didn't get exactly what it say...
> Can anybody help me to understand it?
>
> Thanks...
>
> IOI 98 - Party Lamps:
>
> http://olympiads.win.tue.nl/ioi/ioi98/contest/day1/party/party.html
>
> USACO solution with compelete search:
>
> You are given N lamps and four switches. The first switch toggles all
> lamps, the second the even lamps, the third the odd lamps, and last
> switch toggles lamps 1, 4, 7, 10, ... .
> Given the number of lamps, N, the number of button presses made (up to
> 10,000), and the state of some of the lamps (e.g., lamp 7 is off),
> output all the possible states the lamps could be in.
> Naively, for each button press, you have to try 4 possibilities, for a
> total of 41 (about 106020 ), which means there's no way you could
> do complete search (this particular algorithm would exploit
> recursion).
> Noticing that the order of the button presses does not matter gets
> this number down to about 14 (about 1016 ), still too big to
> completely search (but certainly closer by a factor of over 106000 ).
> However, pressing a button twice is the same as pressing the button no
> times, so all you really have to check is pressing each button either
> 0 or 1 times. That's only 24 = 16 possibilities, surely a number of
> iterations solvable within the time limit.

-- 
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.



[algogeeks] question on algorithm

2011-09-16 Thread prasanth n
Given an infinite number of quarters (25 cents), dimes (10 cents), nickels
(5 cents) and pennies (1 cent), write code to calculate the number of ways
of representing n cents.
also do give an algorithm first..

-- 
*prasanth*

-- 
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] Find the output

2011-09-16 Thread wellwisher
but your programming is giving compilation error
http://ideone.com/sqsNn
the first one is giving output 2 and 5

-- 
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.



[algogeeks] Microsoft Question

2011-09-16 Thread Ankur Garg
 In a matrix of characters, find an string. String can be in any way (all 8
neighbours to be considered)
like find Microsoft in below matrix.

A
C
P
*R
*C*
*X
*S
**O
*P
*C*
V
*O*
V
N
*I*
W
G
*F
**M
*N
Q
A
*T*
I
T

*Any Ideas How to Solve/Approach this problem ?*

-- 
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.



[algogeeks] algorithm problem

2011-09-16 Thread pankaj kumar
You are given two end points ( consider them as two end stations
at some distance  ) there are 100 stations between these two . Now you
need to build a train track between these two end points which
includes only 10 stations and not more than that . Now the objective
is to find such 10 stations such that the maximum distance between any
two consecutive stations is minimum .

mine solution is

 find all  possible subset of 10 elements and answer is that subset
for which sum (of distance  between
consecutive stations )is minimum..
is it correct or any other solution.

-- 
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: royal bank of scotland

2011-09-16 Thread rahul sharma
i was teellling about placement procedure

On Fri, Sep 16, 2011 at 9:12 PM, Rahul Verma wrote:

> Opportunities for the experienced candidates.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/y6n4Hd9fqTQJ.
>
> 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: Tech Mahindra

2011-09-16 Thread Prachi Bhise
Thank you very much for the help.


On Fri, Sep 16, 2011 at 4:37 PM, Ved Garbha  wrote:

> 4.5
>
>
> On Fri, Sep 16, 2011 at 11:45 AM, senthil  wrote:
>
>> HI Prachi,
>>
>> Tech mahindra interveiew will be very easy for you
>> 1st round written xam (online) which has aptitude questions very easy
>> but you need to finish it on time..
>> 2nd round technincal round --questions from your course
>> subjectswill be for an hr but easy...
>> 3rd round HR round ---just for formality.
>>
>> On Sep 14, 7:27 pm, Prachi Bhise  wrote:
>> > Tech Mahidra is going to visit in my collage for recruitment.
>> > Does anyone knows which type of question ask in written test and
>> interview.
>> >
>> > With Regards
>> > Prachi Bhise
>> > B.E (I.T)
>> > Pune University
>>
>> --
>> 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.
>>
>>
>
>
> --
> *Ved Garbha*
>
>
>  --
> 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] Find the output

2011-09-16 Thread Brijesh Upadhyay
&array_name always has the size of whole array...so whenever u increase
this, it will get incremented by size of the whole array..as in this case ,
&a+1 points to next set of 5 numbers

On Fri, Sep 16, 2011 at 10:17 PM, Anup Ghatage  wrote:

> What does one mean by 'address of the whole array' ?
>
>
> On Fri, Sep 16, 2011 at 8:11 PM, mohan kumar wrote:
>
>> thank to explain to this problem...
>>
>>
>>
>> On Fri, Sep 16, 2011 at 1:40 PM, Yogesh Yadav  wrote:
>>
>>> a[]= {1,  2,  3,   4,5}
>>> a
>>>&a
>>>  a+1
>>>   &a+1
>>> &a is address of whole array...so &a+1 means next element after array
>>> completion.
>>>
>>> so ptr-1 will point to 5
>>>
>>> ...
>>>
>>>
>>> On Fri, Sep 16, 2011 at 1:25 PM, Anup Ghatage  wrote:
>>>
 #include
 int main()
 {
 int a[5]={1,2,3,4,5};
 int *ptr=(&a + 1);
 printf("%d %d\n",*(a+1),*(ptr-1));
 return 0;
 }

 Find the output!

 --
 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.
>>>
>>
>>
>>
>> --
>>
>>- *MOHAN 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.
>>
>
>
>
> --
> Anup Ghatage
>
>  --
> 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,
Brijesh Upadhyay
CSE , final year.
Thapar University

-- 
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: Blocked/Unrolled linked list with no duplicates and sorted

2011-09-16 Thread Varun Nagpal
Hi all,
I wrote a pseudo code for a blocked/unrolled single linked list which does
global insertion sort(decreasing order) during insertion of elements in the
list.

Can someone look at pseudocode and let me know if it works correctly? I
think it does! Or do you see any corner cases which might create problems?
I think there might be also be some redundant logic...but I am not able to
figure out? I basically want to make it correct and more legible with
minimum amount of code.

There is also another issue of avoiding wastage due to partially filled
nodes which requires redistributing data between nodes. I am thinking about
some heuristic for this.

*BTW, first here are some test cases and expected results (Note: the sort
order in these test cases is in increasing order, but I wrote the algorithm
for decreasing order)*

eg1: insert 14 in (1,7)->(8,11)->(13,15)->NULL
result: (1,7)->(8,11)->(13,14)->(15,x)->NULL

eg2: insert 14 in (1,7)->(8,11)->(13,15)->(19,x)->NULL
result: (1,7)->(8,11)->(13,14)->(15,19)->NULL

eg3:  (1,2)->(4,5)->NULL and 3 need to be inserted
result: (1,2)->(3,x)->(4,5)->NULL (NO redistribution)

eg4: insert 3 in (1,2)->(4,x)->NULL
result: (1,2)->(3,4)

eg5: (0,7,11,20,40)->(42,71,90,93,100)->NULL and 39 needs to be
inserted *[Assuming
ARRAY_SZ = 5]*
result:  (0,7,11,20,39)->(40,x,x,x,x)->(42,71,90,93,100)->NULL (NO ReDIST)
(lot of space wasted in new Node N as chances of filling it are low and so
redistribution is required)



*And here is the pseudocode for the algorithm*
*--Data structure--*
#define ARRAY_SZ 2
typedef struct node
{
struct node* next;
int Array[ARRAY_SZ];
int last_elem;
}NODE, *NODE_PTR;

*// isNotFull(node) function returns false when node=null or node.Array is
full. true otherwise*

*// Function that inserts element in a blocked linked list and maintains a
global decreasing sort order*
*
*
*Function insert(int elem, NODE_PTR* list): NODE_PTR*
*begin*
NODE_PTR currentNode = *list, startNode = NULL, oldNode = NULL
if(!currentNode)
{
  create newNode
  newNode.next = null
  newNode.last_index=0
  newNode.Array[newNode.last_index] = elem
  return newNode
}

startNode = currentNode
while(currentNode)
{
  if (isNotfull(currentNode))
  {
// we can certainly insert elem in this non-full currentNode if either
next node is null(i.e. currentNode is last node in the list)
// or elem > currentNode.next.Array[0]
if(null == currentNode.next or elem > currentNode.next.Array[0])
{
currentNode.last_index++
insertionsort(elem, currentNode.Array)
return startNode
}
else
{
  // even though currentNode is non-full we cannot insert in it, so we
move to next node
  // TODO: redistribution
  oldNode = currentNode
  currentNode = currentNode.next
}
  }
  else
  {
// currentNode is full

// case : elem should be inserted before currentNode
if(elem > currentNode.Array[0])
{
  if(!oldNode)
  {
// currentNode is the first node of list, so insert a newNode before this
and insert elem in this newNode
create newNode
newNode.Array[newNode.last_index] = elem
newNode.next = currentNode
return newNode
  }
  else
  {
// currentNode is not the first node of the list because a previous node
i.e. oldNode exists
if(isNotfull(oldNode))
{
  insertionsort(elem,oldNode)
  return startNode
}
else
{
  // previous node i.e. oldNode is full, so a newNode must be inserted
between currentNode and oldNode. insert elem in this newNode
  create newNode
  newNode.Array[newNode.last_index] = elem
  oldNode.next = newNode
  newNode.next = currentNode
  return startNode
}
  }
}
// case: elem should be inserted after currentNode. if next node is
null, create new node and insert elem in this new node. else,goto next
node.
else if (elem < currentNode.Array[currentNode.last_index])
{
  if(null == currentNode.next)
  {
// currentNode is last node of the list and is full
create newNode
newNode.Array[newNode.last_index] = elem
newNode.next = null
currentNode.next = newNode
return startNode
  }
  else
  {
// nextNode is not null
if(elem < currentNode.next.Array[0] or isNotfull(currentNode.next))
{
  // element cannot be in-between currentNode and nextNode. it must be
inserted in nextNode or ahead
  oldNode = currentNode
  currentNode = currentNode.next
}
else
{
// => elem > currentNode.next.Array[0] and nextNode is full
// elem must be inserted between currentNode and nextNode
// TODO: redistribution
create newNode
newNode.Array[newNode.last_index] = elem
newNode.next = currentNode.next
currentNode.next = newNode
return startNode
 }
}
  }
}
// case: elem needs to be inserted inside full currentNode
else
{
  if(isNotfull(currentNode.next))
  {
// there is some space in nextNode
insertionsort(currentNode.Array[last_index], currentNode.next)
insertionsort(elem, currentNode)
return startNode;
  }
  else
  {
// nextNode do

[algogeeks] PLEASE HELP ME - Party Lamps

2011-09-16 Thread Blackwizard
I've read this following solution from USACO for "IOI98 - Party Lamps"
problem..but I don't know why 2^4 and I don't know why the complete
search works for this problem...!!!
I didn't get exactly what it say...
Can anybody help me to understand it?

Thanks...



IOI 98 - Party Lamps:

http://olympiads.win.tue.nl/ioi/ioi98/contest/day1/party/party.html


USACO solution with compelete search:

You are given N lamps and four switches. The first switch toggles all
lamps, the second the even lamps, the third the odd lamps, and last
switch toggles lamps 1, 4, 7, 10, ... .
Given the number of lamps, N, the number of button presses made (up to
10,000), and the state of some of the lamps (e.g., lamp 7 is off),
output all the possible states the lamps could be in.
Naively, for each button press, you have to try 4 possibilities, for a
total of 41 (about 106020 ), which means there's no way you could
do complete search (this particular algorithm would exploit
recursion).
Noticing that the order of the button presses does not matter gets
this number down to about 14 (about 1016 ), still too big to
completely search (but certainly closer by a factor of over 106000 ).
However, pressing a button twice is the same as pressing the button no
times, so all you really have to check is pressing each button either
0 or 1 times. That's only 24 = 16 possibilities, surely a number of
iterations solvable within the time limit.

-- 
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] Find the output

2011-09-16 Thread Anup Ghatage
What does one mean by 'address of the whole array' ?

On Fri, Sep 16, 2011 at 8:11 PM, mohan kumar wrote:

> thank to explain to this problem...
>
>
>
> On Fri, Sep 16, 2011 at 1:40 PM, Yogesh Yadav  wrote:
>
>> a[]= {1,  2,  3,   4,5}
>> a
>>&a
>>  a+1
>>   &a+1
>> &a is address of whole array...so &a+1 means next element after array
>> completion.
>>
>> so ptr-1 will point to 5
>>
>> ...
>>
>>
>> On Fri, Sep 16, 2011 at 1:25 PM, Anup Ghatage  wrote:
>>
>>> #include
>>> int main()
>>> {
>>> int a[5]={1,2,3,4,5};
>>> int *ptr=(&a + 1);
>>> printf("%d %d\n",*(a+1),*(ptr-1));
>>> return 0;
>>> }
>>>
>>> Find the output!
>>>
>>> --
>>> 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.
>>
>
>
>
> --
>
>- *MOHAN 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.
>



-- 
Anup Ghatage

-- 
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: no of elements of the array

2011-09-16 Thread Anup Ghatage
When you pass an array as a formal parameter in a function, it decays to a
pointer, so it is mandatory for you to send in the length of the array as
well.

On Fri, Sep 16, 2011 at 9:06 PM, sukran dhawan wrote:

> not possible
>
>
> On Fri, Sep 16, 2011 at 12:17 PM, tech coder wrote:
>
>> +1 to don
>>
>>
>> On Thu, Sep 15, 2011 at 9:40 PM, Don  wrote:
>>
>>> Not really. Usually you would need a second parameter indicating the
>>> size of the input. In theory it might be possible to put a marker
>>> value at the end of the array.
>>>
>>> Most implementations of malloc store the size of the memory block in
>>> the word immediately before the returned address. This is used when
>>> you free the memory. So some programmers use things like:
>>>
>>> int *data = (int *)malloc(n*sizeof(int));
>>>
>>> And then later:
>>> int size = *(data-4)/sizeof(int);
>>>
>>> This would not work if data was declared as an array rather than as a
>>> malloced pointer. It is also completely implementation dependent, so I
>>> would not recommend it for any code which someone may someday have to
>>> maintain.
>>>
>>> Don
>>>
>>> On Sep 15, 10:59 am, rahul vatsa  wrote:
>>> > if i pass an int array to a function, is it possible to find out the no
>>> of
>>> > elements in the called function ?
>>>
>>> --
>>> 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*
>> *"The Coder"*
>>
>> *"Life is a Game. The more u play, the more u win, the more u win , the
>> more successfully u play"*
>>
>>  --
>> 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.
>



-- 
Anup Ghatage

-- 
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-dot Interview Questions

2011-09-16 Thread harshit sethi
somebody reply..

On Fri, Sep 16, 2011 at 8:53 PM, Harshit Sethi wrote:

> hi guys,plzz  share interview questions that are asked in C-dot.
>
> the topics and the key areas from which they raise questions.
> It will be a great helpreply as soon as possible..
>
> Share any information that u have related to c-dot .
>
> God helps those who help themselves :D:D
>
> --
> 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 Interview Question

2011-09-16 Thread Rahul Verma
@Ravi

+1

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/E0NIFwY150EJ.
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: yahoo campus placements

2011-09-16 Thread payal gupta
do share u experiences..n questions if possible 4 sure!!!
thnx..in advance...

Regards,
PAYAL GUPTA,
CSE-3rd yr
NIT-B

On Fri, Sep 16, 2011 at 11:31 AM, siva viknesh wrote:

> http://in.careers.yahoo.com/students/content/186
>
> check this .. it has visited many colleges including trichy NIT ..
> contact them...kindly share ur experience after attending ...
>
> On Sep 15, 8:09 am, Akash Mukherjee  wrote:
> > k...bt its a gud 2 weeks lefti guess der wud be sm other clg visits
> b4
> > dat
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Sep 14, 2011 at 9:22 PM, htross  wrote:
> > > please share the questions asked after the company visits ur campus
> >
> > > On Sep 14, 8:53 pm, Akash Mukherjee  wrote:
> > > > bit mesra, cg 7...dunno nething else :(
> >
> > > > On Wed, Sep 14, 2011 at 3:00 PM, rahul sharma <
> rahul23111...@gmail.com
> > > >wrote:
> >
> > > > > in which col it is cumingn wats is its procedure???waht is cgpa
> > > > > creteria?
> >
> > > > > On Wed, Sep 14, 2011 at 6:26 PM, Akash Mukherjee <
> akash...@gmail.com
> > > >wrote:
> >
> > > > >> anybody has any yahoo campus placements papers/questions or tips
> etc.
> > > > >> please share
> >
> > > > >> thanx in advance
> >
> > > > >> Akash
> >
> > > > >> --
> > > > >> 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] I want resources to learn algorithms on Permutation and Combination problems and Graph algorithms except CLRS..

2011-09-16 Thread Gaurav Menghani
Skiena's Algorithm Design Manual?

On Fri, Sep 16, 2011 at 12:07 PM, kumar raja  wrote:
>
>
> --
> Regards
> Kumar Raja
> M.Tech(SIT)
> IIT Kharagpur,
> 10it60...@iitkgp.ac.in
> 7797137043.
> 09491690115.
>
> --
> 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.
>



-- 
Gaurav Menghani

-- 
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.



[algogeeks] I want resources to learn algorithms on Permutation and Combination problems and Graph algorithms except CLRS..

2011-09-16 Thread kumar raja
-- 
Regards
Kumar Raja
M.Tech(SIT)
IIT Kharagpur,
10it60...@iitkgp.ac.in
7797137043.
09491690115.

-- 
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.



[algogeeks] Re: Easy Dp problem

2011-09-16 Thread Gene
Generating all strings is probably a dead end as the number of strings
is exponential in n and n can be up to 19.

This can be solved as a DP with no counting.

Your grammar is not useful because it's ambiguous.  An LL grammar is S
=  | [ S ] S .

However to enumerate, even the LL grammar is not so useful.

Below is a simple enumerator.  Call it with b(0, 0, n);

char buf[100];

int b(int p, int open, int remaining)
{
  if (open == 0 && remaining == 0)
printf("%.*s\n", p, buf);
  else {
if (open > 0) {
  buf[p] = ']';
  b(p + 1, open - 1, remaining);
}
if (remaining > 0) {
  buf[p] = '[';
  b(p + 1, open + 1, remaining - 1);
}
  }
}

On Sep 16, 11:12 am, "mc2 ."  wrote:
> Hey guys,
>
> I have the following grammar :
> S ->  S{S}S  or  null
>
> i want to generate 2n number of brackets using this grammar. I gave it a try
> but my program is going out of stack.Could someone please help me code this
> grammar?
>
>
>
> On Fri, Sep 16, 2011 at 7:11 PM, mc2 .  wrote:
> > thanks a lot gene. :)
>
> > On Fri, Sep 16, 2011 at 7:00 PM, Gene  wrote:
>
> >> I'll do the 5th example.  A proper bracket expression of size n has n
> >> ['s and n ]'s and every prefix has no more ]'s than ['s.
>
> >> Test case 5 is n = 4 k = 2, so the possible bracket expressions are
>
> >> [][][][] *
> >> [][][[]]
> >> [][[]][]
> >> [][[][]]
> >> [][[[]]]
> >> [[]][][] *
> >> [[]][[]]
> >> [[][]][]
> >> [[][][]]
> >> [[][[]]]
> >> [[[]]][]
> >> [[[]][]]
> >> [[[][]]]
> >> 
>
> >> I have put *'s after the two cases that have [ at positions 5 and 7
> >> (with 1-based indexes).
>
> >> So the answer is 2.
>
> >> On Sep 16, 8:46 am, "mc2 ."  wrote:
> >> > Hey guys,
>
> >> > i am trying to solve this problem :http://www.spoj.pl/problems/SQRBR/
>
> >> > But i can't decipher the problem what it is asking for . Could someone
> >> >  please give test cases for input set 4 and 5?
> >> > What does proper proper bracket expressions mean in these cases?
>
> >> --
> >> 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 Interview Question

2011-09-16 Thread ravi maggon
space of integer depends on the machine you are using. Eg. 32 bit system int
would take 4 bytes. Space taken by the pointer is equal to the space of
address it needs to store. Here it will take 4 bytes to save the address of
a integer.
Correct me if I am wrong.

On Fri, Sep 16, 2011 at 9:23 PM, Rahul Verma wrote:

> How much space does a pointer and integer takes?
> For eg :-
> int a;
> int *a;
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/RmPHywrTUbkJ.
> 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
Ravi Maggon
B.E. CSE, Final Year
Thapar University

www.algorithmguru.com

"*Failure is the opportunity to begin again more intelligently"*

-- 
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: yahoo campus placements

2011-09-16 Thread Rahul Verma
Check the link: http://www.careercup.com/page?pid=yahoo-interview-questions

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/2N_Nig__1foJ.
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.



[algogeeks] Amazon Interview Question

2011-09-16 Thread Rahul Verma
How much space does a pointer and integer takes?
For eg :-
int a;
int *a;

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/RmPHywrTUbkJ.
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: royal bank of scotland

2011-09-16 Thread Rahul Verma
Opportunities for the experienced candidates.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/y6n4Hd9fqTQJ.
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: no of elements of the array

2011-09-16 Thread sukran dhawan
not possible

On Fri, Sep 16, 2011 at 12:17 PM, tech coder wrote:

> +1 to don
>
>
> On Thu, Sep 15, 2011 at 9:40 PM, Don  wrote:
>
>> Not really. Usually you would need a second parameter indicating the
>> size of the input. In theory it might be possible to put a marker
>> value at the end of the array.
>>
>> Most implementations of malloc store the size of the memory block in
>> the word immediately before the returned address. This is used when
>> you free the memory. So some programmers use things like:
>>
>> int *data = (int *)malloc(n*sizeof(int));
>>
>> And then later:
>> int size = *(data-4)/sizeof(int);
>>
>> This would not work if data was declared as an array rather than as a
>> malloced pointer. It is also completely implementation dependent, so I
>> would not recommend it for any code which someone may someday have to
>> maintain.
>>
>> Don
>>
>> On Sep 15, 10:59 am, rahul vatsa  wrote:
>> > if i pass an int array to a function, is it possible to find out the no
>> of
>> > elements in the called function ?
>>
>> --
>> 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*
> *"The Coder"*
>
> *"Life is a Game. The more u play, the more u win, the more u win , the
> more successfully u play"*
>
>  --
> 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: royal bank of scotland

2011-09-16 Thread harshit sethi
i don't know about the procedure for placement,i am also waiting for rbs to
come.

On Fri, Sep 16, 2011 at 8:58 PM, aashish bansal wrote:

> i am sorry..surely they must have shortlisted on the basis of elitmus
> score.But what min elitmus score is required or they shortlist top 20-30
> people based on elitmus score??i am still unclear as to how they shortlist
> people for interviews.
>
> On Fri, Sep 16, 2011 at 6:03 PM, Dheeraj Sharma <
> dheerajsharma1...@gmail.com> wrote:
>
>> yeah...correct ..
>>
>> On Fri, Sep 16, 2011 at 5:57 PM, rahul sharma wrote:
>>
>>> cpa:- 6
>>>
>>> elitmus considered 100%
>>>
>>> packakge around 7-7.5
>>>
>>>
>>> On Fri, Sep 16, 2011 at 1:36 PM, siva viknesh wrote:
>>>
 and also package??

 On Sep 16, 12:24 pm, aashish bansal  wrote:
 > and what is their shortlisting criteria?do they consider elitmus score
 > only or percentage as well?
 >
 > On Sep 14, 8:01 pm, rahul sharma  wrote:
 >
 >
 >
 >
 >
 >
 >
 > > they take elitmus test..and then interviewws
 >
 > > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand <
 swinyanand...@gmail.com>wrote:
 >
 > > > wat is selection procedure of RBS (for internships or placements)
 >
 > > > --
 > > > 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.
>>>
>>
>>
>>
>> --
>> *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.
>>
>
>
>
> --
> Aashish bansal
>
> Undergraduate Student
> Bachelor of Engineering (Information Technology)
> Netaji Subhas Institute of Technology
> University of Delhi, Dwarka sector-3
> New Delhi
> --
> 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: royal bank of scotland

2011-09-16 Thread aashish bansal
i am sorry..surely they must have shortlisted on the basis of elitmus
score.But what min elitmus score is required or they shortlist top 20-30
people based on elitmus score??i am still unclear as to how they shortlist
people for interviews.

On Fri, Sep 16, 2011 at 6:03 PM, Dheeraj Sharma  wrote:

> yeah...correct ..
>
> On Fri, Sep 16, 2011 at 5:57 PM, rahul sharma wrote:
>
>> cpa:- 6
>>
>> elitmus considered 100%
>>
>> packakge around 7-7.5
>>
>>
>> On Fri, Sep 16, 2011 at 1:36 PM, siva viknesh wrote:
>>
>>> and also package??
>>>
>>> On Sep 16, 12:24 pm, aashish bansal  wrote:
>>> > and what is their shortlisting criteria?do they consider elitmus score
>>> > only or percentage as well?
>>> >
>>> > On Sep 14, 8:01 pm, rahul sharma  wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > they take elitmus test..and then interviewws
>>> >
>>> > > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand <
>>> swinyanand...@gmail.com>wrote:
>>> >
>>> > > > wat is selection procedure of RBS (for internships or placements)
>>> >
>>> > > > --
>>> > > > 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.
>>
>
>
>
> --
> *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.
>



-- 
Aashish bansal

Undergraduate Student
Bachelor of Engineering (Information Technology)
Netaji Subhas Institute of Technology
University of Delhi, Dwarka sector-3
New Delhi

-- 
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: royal bank of scotland

2011-09-16 Thread harshit sethi
they do not take elitmus test for internship.Shortlisting is done on basis
of percentage.



On Fri, Sep 16, 2011 at 6:03 PM, Dheeraj Sharma  wrote:

> yeah...correct ..
>
> On Fri, Sep 16, 2011 at 5:57 PM, rahul sharma wrote:
>
>> cpa:- 6
>>
>> elitmus considered 100%
>>
>> packakge around 7-7.5
>>
>>
>> On Fri, Sep 16, 2011 at 1:36 PM, siva viknesh wrote:
>>
>>> and also package??
>>>
>>> On Sep 16, 12:24 pm, aashish bansal  wrote:
>>> > and what is their shortlisting criteria?do they consider elitmus score
>>> > only or percentage as well?
>>> >
>>> > On Sep 14, 8:01 pm, rahul sharma  wrote:
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > > they take elitmus test..and then interviewws
>>> >
>>> > > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand <
>>> swinyanand...@gmail.com>wrote:
>>> >
>>> > > > wat is selection procedure of RBS (for internships or placements)
>>> >
>>> > > > --
>>> > > > 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.
>>
>
>
>
> --
> *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.



[algogeeks] C-dot Interview Questions

2011-09-16 Thread Harshit Sethi
hi guys,plzz  share interview questions that are asked in C-dot.

the topics and the key areas from which they raise questions.
It will be a great helpreply as soon as possible..

Share any information that u have related to c-dot .

God helps those who help themselves :D:D

-- 
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] Symantec

2011-09-16 Thread sukran dhawan
which college ? and package ?

On Fri, Sep 16, 2011 at 7:39 PM, siva viknesh wrote:

> Hi
>
> Symantec is comin to our collanyone if attended plz share
> written pattern and interview ques...thanks
>
> --
> 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.



[algogeeks] Re: hash

2011-09-16 Thread Don
There are entire books on the subject, so I can't give you everything,
but here's a quick summary:

First you need a hash function which maps your input to an index in
the table. Hashing strings is a common application, and there are a
lot of string hash functions. Most common is something like this:

int hash(char *s)
{
  int result = 0;
  for(int i = 0; s[i]; ++i)
result = 17 * result + s[i];
  return result;
}

You would then use mod to map the return value into the size of the
hash table.

There are better hash functions, but that one is not bad for most
purposes.

The next issue to deal with his how to handle collisions. There is
always the possibility that two values will map to the same spot in
the hash table, and the more full the table gets, the more that will
happen.

The most basic method is linear probing, in which you simply check the
next slot, and then the next, etc. until you find an empty slot. There
are several problems with this scheme. First, as the table gets full
it tends to create big clumps of filled cells, which reduces the
efficiency of searching and adding to the table. Secondly, when you
want to delete from the table, you might leave some other element in a
spot where it won't be found. That's because with this scheme, the
search table method must look in the location indicated by the hash
function, and if it is occupied, it must search each cell until it
finds one which matches or until it reaches an empty cell. If you
deleted one of the elements between the hash value of the element you
are searching for and the location where it was ultimately stored, you
will run into trouble if you are not careful. This is typically
addressed by marking a cell where an element has been deleted as
"deleted". Then the search knows to keep looking past that location. A
cleanup can be run occasionally to put things back closer to where
they should be, but the cleanup is costly in terms of time, so you
don't want to do it too often.

Using a rehash function is a better way to deal with collisions. The
rehash is a different hash function which puts the element in another
location. I like to use a hash function which has a second parameter
which defaults to zero, but other values can be used to rehash a
string. Here is one:

int hash(char *str, int rehash=0)
{
  int result = rehash;
  for(int i = 0; s[i]; ++i)
result ^= s[result^str[i]];   // s[] is a permutation of values
0..255
  return result;
}

This has the nice characteristic that if hash(s1) == hash(s2),
hash(s1,1) and hash(s2,1) are likely to be different.

In some cases you can design a hash function which avoids collisions.
If you have 100 known strings to hash, you can usually use the second
function above and find a permutation s which results in no
collisions. Better yet, if you can control the hash tags, you can
ensure no collisions. In one case I was managing a set of up to N
items, and each one had a unique id tag. The tags didn't need to be
sequential, but each one had to be unique. So I assigned the tags by
building a queue of integers initialized with values 1..N. When I
needed an id for a new item I pulled it out of the queue, and when an
item was deleted, I added N to it's id and put that id into the queue.
This guaranteed that a hash function of id%N would never generate
collisions.

One of my favorite ways to deal with collisions is to have each cell
in the table be a bucket which can contain multiple elements. Making
it be a binary search tree is very nice, because it makes resolving
collisions into an O(ln n) operation rather than O(n) for linear
probing. If you already have a binary search tree class, you can just
make a table of them to use as a hash table.

In most cases you need to design in the ability to delete elements
from the hash table. If you don't need that ability, that makes your
job easier, but most applications do require it. You must make sure
that deleting one item doesn't affect searches on other items, and
that repeated insertions and deletes don't degrade the performance of
the hash table.

Chosing the right size for a hash table is very important. Hash table
performance degrades significantly when the table gets more than half
full. By the time it is 80% full you might as well be using a linear
search. Some hash systems use variable sized hash tables. But changing
size is very expensive because you must reinsert all the items into
the new table. You are better off, when possible, picking the right
size to start with.

There are many schools of thought on hashing, and many ways to tailor
a hashing system to a particular need. Think about the requirements of
your application and look for the best way to accomplish your specific
task.

I hope this helps.

Don

On Sep 16, 9:17 am, prasanth n  wrote:
> can anyone tell how to implement a hash table in C?? how to choose the hash
> function?? algorithm??
>
> --
> *prasanth*

-- 
You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Easy Dp problem

2011-09-16 Thread mc2 .
Hey guys,

I have the following grammar :
S ->  S{S}S  or  null

i want to generate 2n number of brackets using this grammar. I gave it a try
but my program is going out of stack.Could someone please help me code this
grammar?

On Fri, Sep 16, 2011 at 7:11 PM, mc2 .  wrote:

> thanks a lot gene. :)
>
>
> On Fri, Sep 16, 2011 at 7:00 PM, Gene  wrote:
>
>> I'll do the 5th example.  A proper bracket expression of size n has n
>> ['s and n ]'s and every prefix has no more ]'s than ['s.
>>
>> Test case 5 is n = 4 k = 2, so the possible bracket expressions are
>>
>> [][][][] *
>> [][][[]]
>> [][[]][]
>> [][[][]]
>> [][[[]]]
>> [[]][][] *
>> [[]][[]]
>> [[][]][]
>> [[][][]]
>> [[][[]]]
>> [[[]]][]
>> [[[]][]]
>> [[[][]]]
>> 
>>
>> I have put *'s after the two cases that have [ at positions 5 and 7
>> (with 1-based indexes).
>>
>> So the answer is 2.
>>
>> On Sep 16, 8:46 am, "mc2 ."  wrote:
>> > Hey guys,
>> >
>> > i am trying to solve this problem :http://www.spoj.pl/problems/SQRBR/
>> >
>> > But i can't decipher the problem what it is asking for . Could someone
>> >  please give test cases for input set 4 and 5?
>> > What does proper proper bracket expressions mean in these cases?
>>
>> --
>> 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] Find the output

2011-09-16 Thread mohan kumar
thank to explain to this problem...


On Fri, Sep 16, 2011 at 1:40 PM, Yogesh Yadav  wrote:

> a[]= {1,  2,  3,   4,5}
> a
>&a
>  a+1
>   &a+1
> &a is address of whole array...so &a+1 means next element after array
> completion.
>
> so ptr-1 will point to 5
>
> ...
>
>
> On Fri, Sep 16, 2011 at 1:25 PM, Anup Ghatage  wrote:
>
>> #include
>> int main()
>> {
>> int a[5]={1,2,3,4,5};
>> int *ptr=(&a + 1);
>> printf("%d %d\n",*(a+1),*(ptr-1));
>> return 0;
>> }
>>
>> Find the output!
>>
>> --
>> 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.
>



-- 

   - *MOHAN 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.



[algogeeks] hash

2011-09-16 Thread prasanth n
can anyone tell how to implement a hash table in C?? how to choose the hash
function?? algorithm??

-- 
*prasanth*

-- 
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] Find the element in Array

2011-09-16 Thread prasanth n
@sarath:

it is not specified that the range is from 1 to n..it may look like this:
1 99 2 99

here you cant access a[99]..

On Fri, Sep 16, 2011 at 7:28 PM, sarath prasath wrote:

> this is one is the elegant solution i came across
> if u got an element just go to the elements index and mark the value to its
> negative...
> say for eg:
> if u got a[i]=9;
> then go to a[9] and make it as
> a[9]=-a[9];
> then do like this for all the elements in the array
> so now u can get the logic to how to find the element which is present
> twice...
>
>
>
> On Wed, Aug 31, 2011 at 11:32 AM, Navneet Gupta wrote:
>
>> You are given an array. One integer is in the array twice and others
>> are unique. Find that no. O(n) Solution
>>
>> --
>> Regards,
>> Navneet
>>
>> --
>> 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.
>



-- 
*prasanth*

-- 
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.



[algogeeks] Symantec

2011-09-16 Thread siva viknesh
Hi

 Symantec is comin to our collanyone if attended plz share
written pattern and interview ques...thanks

-- 
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] Find the element in Array

2011-09-16 Thread sarath prasath
this is one is the elegant solution i came across
if u got an element just go to the elements index and mark the value to its
negative...
say for eg:
if u got a[i]=9;
then go to a[9] and make it as
a[9]=-a[9];
then do like this for all the elements in the array
so now u can get the logic to how to find the element which is present
twice...


On Wed, Aug 31, 2011 at 11:32 AM, Navneet Gupta wrote:

> You are given an array. One integer is in the array twice and others
> are unique. Find that no. O(n) Solution
>
> --
> Regards,
> Navneet
>
> --
> 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: Easy Dp problem

2011-09-16 Thread mc2 .
thanks a lot gene. :)

On Fri, Sep 16, 2011 at 7:00 PM, Gene  wrote:

> I'll do the 5th example.  A proper bracket expression of size n has n
> ['s and n ]'s and every prefix has no more ]'s than ['s.
>
> Test case 5 is n = 4 k = 2, so the possible bracket expressions are
>
> [][][][] *
> [][][[]]
> [][[]][]
> [][[][]]
> [][[[]]]
> [[]][][] *
> [[]][[]]
> [[][]][]
> [[][][]]
> [[][[]]]
> [[[]]][]
> [[[]][]]
> [[[][]]]
> 
>
> I have put *'s after the two cases that have [ at positions 5 and 7
> (with 1-based indexes).
>
> So the answer is 2.
>
> On Sep 16, 8:46 am, "mc2 ."  wrote:
> > Hey guys,
> >
> > i am trying to solve this problem :http://www.spoj.pl/problems/SQRBR/
> >
> > But i can't decipher the problem what it is asking for . Could someone
> >  please give test cases for input set 4 and 5?
> > What does proper proper bracket expressions mean in these cases?
>
> --
> 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.



[algogeeks] Re: Easy Dp problem

2011-09-16 Thread Gene
I'll do the 5th example.  A proper bracket expression of size n has n
['s and n ]'s and every prefix has no more ]'s than ['s.

Test case 5 is n = 4 k = 2, so the possible bracket expressions are

[][][][] *
[][][[]]
[][[]][]
[][[][]]
[][[[]]]
[[]][][] *
[[]][[]]
[[][]][]
[[][][]]
[[][[]]]
[[[]]][]
[[[]][]]
[[[][]]]


I have put *'s after the two cases that have [ at positions 5 and 7
(with 1-based indexes).

So the answer is 2.

On Sep 16, 8:46 am, "mc2 ."  wrote:
> Hey guys,
>
> i am trying to solve this problem :http://www.spoj.pl/problems/SQRBR/
>
> But i can't decipher the problem what it is asking for . Could someone
>  please give test cases for input set 4 and 5?
> What does proper proper bracket expressions mean in these cases?

-- 
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] Easy Dp problem

2011-09-16 Thread Tamanna Afroze
couldn't understand the problem

-- 
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.



[algogeeks] Easy Dp problem

2011-09-16 Thread mc2 .
Hey guys,

i am trying to solve this problem :
http://www.spoj.pl/problems/SQRBR/

But i can't decipher the problem what it is asking for . Could someone
 please give test cases for input set 4 and 5?
What does proper proper bracket expressions mean in these cases?

-- 
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: royal bank of scotland

2011-09-16 Thread Dheeraj Sharma
yeah...correct ..

On Fri, Sep 16, 2011 at 5:57 PM, rahul sharma wrote:

> cpa:- 6
>
> elitmus considered 100%
>
> packakge around 7-7.5
>
>
> On Fri, Sep 16, 2011 at 1:36 PM, siva viknesh wrote:
>
>> and also package??
>>
>> On Sep 16, 12:24 pm, aashish bansal  wrote:
>> > and what is their shortlisting criteria?do they consider elitmus score
>> > only or percentage as well?
>> >
>> > On Sep 14, 8:01 pm, rahul sharma  wrote:
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > > they take elitmus test..and then interviewws
>> >
>> > > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand <
>> swinyanand...@gmail.com>wrote:
>> >
>> > > > wat is selection procedure of RBS (for internships or placements)
>> >
>> > > > --
>> > > > 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.
>



-- 
*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.



Re: [algogeeks] Re: royal bank of scotland

2011-09-16 Thread rahul sharma
cpa:- 6

elitmus considered 100%

packakge around 7-7.5

On Fri, Sep 16, 2011 at 1:36 PM, siva viknesh wrote:

> and also package??
>
> On Sep 16, 12:24 pm, aashish bansal  wrote:
> > and what is their shortlisting criteria?do they consider elitmus score
> > only or percentage as well?
> >
> > On Sep 14, 8:01 pm, rahul sharma  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > they take elitmus test..and then interviewws
> >
> > > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand <
> swinyanand...@gmail.com>wrote:
> >
> > > > wat is selection procedure of RBS (for internships or placements)
> >
> > > > --
> > > > 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] Find the output

2011-09-16 Thread Prateek Jain
Brijesh is right.until u do the type casting it will show an error

On Fri, Sep 16, 2011 at 5:57 AM, Pradip Singh  wrote:

> it will print 2,5
>
> On Fri, Sep 16, 2011 at 2:35 AM, Brijesh wrote:
>
>>
>>>
>> On Friday, 16 September 2011 13:25:38 UTC+5:30, Anup wrote:
>>>
>>> #include
>>> int main()
>>> {
>>> int a[5]={1,2,3,4,5};
>>> int *ptr=(&a + 1);
>>>
>>int *ptr=(int *)(&a + 1);
>>
>>> printf("%d %d\n",*(a+1),*(ptr-1));
>>> return 0;
>>> }
>>>
>>> Find the output!
>>>
>>
>> Now it will print 2 5
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/algogeeks/-/4tXlbiojgm8J.
>>
>> 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: Tech Mahindra

2011-09-16 Thread Ved Garbha
4.5

On Fri, Sep 16, 2011 at 11:45 AM, senthil  wrote:

> HI Prachi,
>
> Tech mahindra interveiew will be very easy for you
> 1st round written xam (online) which has aptitude questions very easy
> but you need to finish it on time..
> 2nd round technincal round --questions from your course
> subjectswill be for an hr but easy...
> 3rd round HR round ---just for formality.
>
> On Sep 14, 7:27 pm, Prachi Bhise  wrote:
> > Tech Mahidra is going to visit in my collage for recruitment.
> > Does anyone knows which type of question ask in written test and
> interview.
> >
> > With Regards
> > Prachi Bhise
> > B.E (I.T)
> > Pune University
>
> --
> 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.
>
>


-- 
*Ved Garbha*

-- 
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.



[algogeeks] Re: Question --> plz answer

2011-09-16 Thread Gene
Sorry.  Small mistake.  First test should have been

> W(n,k) = (k < 1 || k > n) ? 0 :

This is fixed below.

On Sep 16, 4:48 am, Gene  wrote:
> My guess is that the "and so on..." means we should be able to solve
> this assuming the pyramid is as high as it needs to be in order not
> to
> overflow.
>
> With this the problem gets more interesting.  I worked it out a bit
> farther:
>
> L/C --- Filled cups
> 1 --- 1
> 3 --- 2,3
> 5 --- 5
> 7 --- 4-6
> 8 1/3 --- 8,9
> 11 --- 13
> 13 2/3 --- 12, 14
> 15 --- 7,10
>
> At this point, 17,20 are 1/8 full and 18,19 are 7/8 full.  11,15 are
> empty but beginning to receive water.
>
> After looking at the cockeyed for a while I think it's a simple
> dynamic program:
>
> First let's number the cups differently with pairs (n, k) where n is
> the level number -- top is n=1 -- and k is the ordinal within a level
> -- left is k=1.  So
> at every level n you have (n,1)(n,2) ... (n,n).  Note that n(n-1)/2+k
> gives the numbering in the original problem, so it's easy to convert.
>
> Let W(n,k) be the amount of water that flowed into cup (n,k) after L
> has been poured in at the top.  Then
>
> W(n,k) = (k < 1 || k > n) ? 0 :
>         (n == 1) ? L :
>          max(0, (W(n - 1, k - 1) - C) / 2) + max(0, (W(n - 1, k) -
> C) / 2)
>
> The last line says that the amount that flowed into this cup is equal
> to what's flowed out of the two parents. In turn, what flowed out of a
> parent is half of what flowed in after its capacity C was filled.  Of
> course if that's a negative amount, it's corrected to 0.
>
> The answer to the final question of how much water is in cup (n,k)
> after L has been poured into the top cup is
>
> W(n,k) > C ? C : W(n,k)
>
> On Sep 10, 2:42 pm, Dave  wrote:
>
>
>
> > @Ishan: Here is the algorithm:
>
> > If L <= C, then
> >     cup1 = L
> >     cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0
> > else if L < 3*C, then
> >     cup1 = C
> >     cup2 = cup3 = (L-C)/2
> >     cup4 = cup5 = cup6 = overflow = 0
> > else if L < 5*C, then
> >     cup1 = cup2 = cup3 = C
> >     cup4 = cup6 = (L-3*C)/4
> >     cup5 = (L-3*C)/2
> >     overflow = 0
> > else if L < 7*C, then
> >     cup1 = cup2 = cup3 = cup5 = C
> >     cup4 = cup6 = (L-3*C)/4
> >     overflow = (L-5*C)/2
> > else if L >= 7*C, then
> >     cup1 = cup2 = cup3 = cup4 = cup5 = cup6 = C
> >     overflow = L-6*C
>
> > And so on.
>
> > Dave
>
> > On Sep 10, 9:40 am, Ishan Aggarwal 
> > wrote:
>
> > > 1.)
>
> > > there is apyramidwith 1 cup at level , 2 at level 2 , 3 at level 3 and so
> > > on..
> > > It looks something like this
> > > 1
> > > 2 3
> > > 4 5 6
> > > every cup has capacity C. you pour L liters of water from top . when cup 1
> > > gets filled , it overflows to cup 2,3 equally, and when they get filled ,
> > > Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both 
> > > the
> > > cups and so on.
> > > Now given C and M .Find the amount of water in ith cup.
>
> > > --
> > > 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.



Re: [algogeeks] Find the output

2011-09-16 Thread Pradip Singh
it will print 2,5

On Fri, Sep 16, 2011 at 2:35 AM, Brijesh wrote:

>
>>
> On Friday, 16 September 2011 13:25:38 UTC+5:30, Anup wrote:
>>
>> #include
>> int main()
>> {
>> int a[5]={1,2,3,4,5};
>> int *ptr=(&a + 1);
>>
>int *ptr=(int *)(&a + 1);
>
>> printf("%d %d\n",*(a+1),*(ptr-1));
>> return 0;
>> }
>>
>> Find the output!
>>
>
> Now it will print 2 5
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/4tXlbiojgm8J.
>
> 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] Find the output

2011-09-16 Thread Brijesh

>
>
>
On Friday, 16 September 2011 13:25:38 UTC+5:30, Anup wrote:
>
> #include
> int main()
> {
> int a[5]={1,2,3,4,5};
> int *ptr=(&a + 1);
>
   int *ptr=(int *)(&a + 1);

> printf("%d %d\n",*(a+1),*(ptr-1));
> return 0;
> }
>
> Find the output!
>

Now it will print 2 5 

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/4tXlbiojgm8J.
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.



[algogeeks] Re: Find the output

2011-09-16 Thread abhishek

compile time error
On Sep 16, 12:55 pm, Anup Ghatage  wrote:
> #include
> int main()
> {
> int a[5]={1,2,3,4,5};
> int *ptr=(&a + 1);
> printf("%d %d\n",*(a+1),*(ptr-1));
> return 0;
>
> }
>
> Find the output!

-- 
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.



[algogeeks] Re: Question --> plz answer

2011-09-16 Thread Gene
My guess is that the "and so on..." means we should be able to solve
this assuming the pyramid is as high as it needs to be in order not
to
overflow.

With this the problem gets more interesting.  I worked it out a bit
farther:


L/C --- Filled cups
1 --- 1
3 --- 2,3
5 --- 5
7 --- 4-6
8 1/3 --- 8,9
11 --- 13
13 2/3 --- 12, 14
15 --- 7,10

At this point, 17,20 are 1/8 full and 18,19 are 7/8 full.  11,15 are
empty but beginning to receive water.

After looking at the cockeyed for a while I think it's a simple
dynamic program:

First let's number the cups differently with pairs (n, k) where n is
the level number -- top is n=1 -- and k is the ordinal within a level
-- left is k=1.  So
at every level n you have (n,1)(n,2) ... (n,n).  Note that n(n-1)/2+k
gives the numbering in the original problem, so it's easy to convert.

Let W(n,k) be the amount of water that flowed into cup (n,k) after L
has been poured in at the top.  Then

W(n,k) = (k < 1) ? 0 :
(n == 1) ? L :
 max(0, (W(n - 1, k - 1) - C) / 2) + max(0, (W(n - 1, k) -
C) / 2)

The last line says that the amount that flowed into this cup is equal
to what's flowed out of the two parents. In turn, what flowed out of a
parent is half of what flowed in after its capacity C was filled.  Of
course if that's a negative amount, it's corrected to 0.

The answer to the final question of how much water is in cup (n,k)
after L has been poured into the top cup is

W(n,k) > C ? C : W(n,k)

On Sep 10, 2:42 pm, Dave  wrote:
> @Ishan: Here is the algorithm:
>
> If L <= C, then
>     cup1 = L
>     cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0
> else if L < 3*C, then
>     cup1 = C
>     cup2 = cup3 = (L-C)/2
>     cup4 = cup5 = cup6 = overflow = 0
> else if L < 5*C, then
>     cup1 = cup2 = cup3 = C
>     cup4 = cup6 = (L-3*C)/4
>     cup5 = (L-3*C)/2
>     overflow = 0
> else if L < 7*C, then
>     cup1 = cup2 = cup3 = cup5 = C
>     cup4 = cup6 = (L-3*C)/4
>     overflow = (L-5*C)/2
> else if L >= 7*C, then
>     cup1 = cup2 = cup3 = cup4 = cup5 = cup6 = C
>     overflow = L-6*C
>
> And so on.
>
> Dave
>
> On Sep 10, 9:40 am, Ishan Aggarwal 
> wrote:
>
>
>
> > 1.)
>
> > there is apyramidwith 1 cup at level , 2 at level 2 , 3 at level 3 and so
> > on..
> > It looks something like this
> > 1
> > 2 3
> > 4 5 6
> > every cup has capacity C. you pour L liters of water from top . when cup 1
> > gets filled , it overflows to cup 2,3 equally, and when they get filled ,
> > Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the
> > cups and so on.
> > Now given C and M .Find the amount of water in ith cup.
>
> > --
> > 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.



Re: [algogeeks] Re: Party Lamps

2011-09-16 Thread Mohammad Reza Rahmani
>
> Yeah..I've got it...you're true;

1 , 7 , 13 , 19 , ...
4 , 10 , 16 , 22 , ...
 have the same state...
but what about 2 , 3 , 5 , 6 , 8 , 9 , ...?

-- 
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] Find the output

2011-09-16 Thread Yogesh Yadav
a[]= {1,  2,  3,   4,5}
a
   &a
 a+1
  &a+1
&a is address of whole array...so &a+1 means next element after array
completion.

so ptr-1 will point to 5

...

On Fri, Sep 16, 2011 at 1:25 PM, Anup Ghatage  wrote:

> #include
> int main()
> {
> int a[5]={1,2,3,4,5};
> int *ptr=(&a + 1);
> printf("%d %d\n",*(a+1),*(ptr-1));
> return 0;
> }
>
> Find the output!
>
> --
> 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.



[algogeeks] Re: royal bank of scotland

2011-09-16 Thread siva viknesh
and also package??

On Sep 16, 12:24 pm, aashish bansal  wrote:
> and what is their shortlisting criteria?do they consider elitmus score
> only or percentage as well?
>
> On Sep 14, 8:01 pm, rahul sharma  wrote:
>
>
>
>
>
>
>
> > they take elitmus test..and then interviewws
>
> > On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand 
> > wrote:
>
> > > wat is selection procedure of RBS (for internships or placements)
>
> > > --
> > > 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] An interesting question

2011-09-16 Thread DeVaNsH gUpTa
Saurabh, the compiler used in all the cases is gcc 4.3.4 and these examples
shows different behavior of c and c++ rather than gcc and g++.

-- 
Thanks and Regards
*Devansh Gupta*
*B.Tech Third Year*
*MNNIT, Allahabad*

-- 
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] Book for C++

2011-09-16 Thread sharmila saru
Balagurusamy

On Mon, Sep 12, 2011 at 1:43 PM, Ankuj Gupta  wrote:

> Hi
>
> Which is a good book for C++ ( Robert Lafore or Bjarne Stroustrup or
> Herbert Schildt) ?
>
> Ankuj
>
> --
> 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.



[algogeeks] Find the output

2011-09-16 Thread Anup Ghatage
#include
int main()
{
int a[5]={1,2,3,4,5};
int *ptr=(&a + 1);
printf("%d %d\n",*(a+1),*(ptr-1));
return 0;
}

Find the output!

-- 
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: Party Lamps

2011-09-16 Thread Mohammad Reza Rahmani
I've read this following solution from USACO...but I don't know why 2^4 and
I don't know why the complete search works for this problem...!!!

Plz Help Me...

Thanks...


You are given N lamps and four switches. The first switch toggles all lamps,
the second the even lamps, the third the odd lamps, and last switch toggles
lamps 1, 4, 7, 10, ... .

Given the number of lamps, *N*, the number of button presses made (up to
10,000), and the state of some of the lamps (e.g., lamp 7 is off), output
all the possible states the lamps could be in.

Naively, for each button press, you have to try 4 possibilities, for a total
of 41 (about 106020 ), which means there's no way you could do complete
search (this particular algorithm would exploit recursion).

Noticing that the order of the button presses does not matter gets this
number down to about 14 (about 1016 ), still too big to completely
search (but certainly closer by a factor of over 106000 ).

However, pressing a button twice is the same as pressing the button no
times, so all you really have to check is pressing each button either 0 or 1
times. That's only 24 = 16 possibilities, surely a number of iterations
solvable within the time limit.

-- 
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.



[algogeeks] Re: Thoughtworks and Tejas network

2011-09-16 Thread siva viknesh
check the groupsi have posted some 5 mails ...those ppl ask those
same ques repeatedly ..if u prepare well and strong in basics of all
areas of CS mainly oops u can crack it

On Sep 14, 7:36 pm, amrit harry  wrote:
> dey would only look for OPPS concept with proper working knowledge and DB
> concepts..
>
> On Tue, Sep 13, 2011 at 8:15 PM, Brijesh wrote:
>
> > yes..please anyone post questions asked in  thoughtworks interview
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To view this discussion on the web visit
> >https://groups.google.com/d/msg/algogeeks/-/Rpd5yw77HbMJ.
> > 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.
>
> --
> AMRIT

-- 
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.



[algogeeks] Re: royal bank of scotland

2011-09-16 Thread aashish bansal
and what is their shortlisting criteria?do they consider elitmus score
only or percentage as well?

On Sep 14, 8:01 pm, rahul sharma  wrote:
> they take elitmus test..and then interviewws
>
> On Wed, Sep 14, 2011 at 12:17 PM, deepikaanand wrote:
>
>
>
>
>
>
>
> > wat is selection procedure of RBS (for internships or placements)
>
> > --
> > 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.



[algogeeks] Re: Question --> plz answer

2011-09-16 Thread Gene
My guess is that the "and so on..." means we should be able to solve
this assuming the pyramid is as high as it needs to be in order not to
overflow.

With this the problem gets more interesting.  I worked it out a bit
farther:

L/C --- Filled cups
1 --- 1
3 --- 2,3
5 --- 5
7 --- 4-6
8 1/3 --- 8,9
11 --- 13
13 2/3 --- 12, 14
15 --- 7,10

At this point, 17,20 are 1/8 full and 18,19 are 7/8 full.  11,15 are
empty but beginning to receive water.

I know I can build a simulation of what I'm doing by hand to always
get the answer, but I'm thinking there is a simple recurrence or other
algorithm.  Any anybody see it?

Gene

On Sep 10, 2:42 pm, Dave  wrote:
> @Ishan: Here is the algorithm:
>
> If L <= C, then
>     cup1 = L
>     cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0
> else if L < 3*C, then
>     cup1 = C
>     cup2 = cup3 = (L-C)/2
>     cup4 = cup5 = cup6 = overflow = 0
> else if L < 5*C, then
>     cup1 = cup2 = cup3 = C
>     cup4 = cup6 = (L-3*C)/4
>     cup5 = (L-3*C)/2
>     overflow = 0
> else if L < 7*C, then
>     cup1 = cup2 = cup3 = cup5 = C
>     cup4 = cup6 = (L-3*C)/4
>     overflow = (L-5*C)/2
> else if L >= 7*C, then
>     cup1 = cup2 = cup3 = cup4 = cup5 = cup6 = C
>     overflow = L-6*C
>
> And so on.
>
> Dave
>
> On Sep 10, 9:40 am, Ishan Aggarwal 
> wrote:
>
>
>
> > 1.)
>
> > there is apyramidwith 1 cup at level , 2 at level 2 , 3 at level 3 and so
> > on..
> > It looks something like this
> > 1
> > 2 3
> > 4 5 6
> > every cup has capacity C. you pour L liters of water from top . when cup 1
> > gets filled , it overflows to cup 2,3 equally, and when they get filled ,
> > Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the
> > cups and so on.
> > Now given C and M .Find the amount of water in ith cup.
>
> > --
> > 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.



Re: [algogeeks] C++ Query...

2011-09-16 Thread Anup Ghatage
You create another class which has the same structure as the given class.
and then create an object of the temporary class and typecast given object
into this new class object, and then access its element.

On Fri, Sep 16, 2011 at 10:04 AM, siddharam suresh
wrote:

> i saw better solution in stack over flow, but these things violates the
> Memory rules of C++
> Thank you,
> Sid.
>
>
>
> On Thu, Sep 15, 2011 at 6:41 PM, teja bala wrote:
>
>> @ BHARATH
>>
>> exactly very thx
>>
>>
>> On Thu, Sep 15, 2011 at 5:22 PM, bharatkumar bagana <
>> bagana.bharatku...@gmail.com> wrote:
>>
>>> @teja : r u looking for something like this...
>>> #include
>>> #include
>>> class Hai
>>> {
>>>  public :
>>> int* getPointerToPrivate()
>>> {
>>> return &i;
>>> }
>>> void setI(int j)
>>> {
>>> i=j;
>>> }
>>>  private:
>>> int i;
>>> };
>>> main()
>>> {
>>>  Hai h;
>>>  h.setI(10);
>>>  int *i=h.getPointerToPrivate();
>>>  printf("%d",*i);
>>>
>>> }
>>>
>>> On Thu, Sep 15, 2011 at 6:41 AM, teja bala wrote:
>>>
 How to access class private data members with a pointer?

 thx in advance?

 --
 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.


>>>
>>>
>>> --
>>>
>>> **Please do not print this e-mail until urgent requirement. Go Green!!
>>> Save Papers <=> Save Trees
>>> *BharatKumar Bagana*
>>> **http://www.google.com/profiles/bagana.bharatkumar
>>> *
>>> Mobile +91 8056127652*
>>> 
>>>
>>>
>>>  --
>>> 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.
>



-- 
Anup Ghatage

-- 
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.