Re: [algogeeks] Amazon Question

2011-03-02 Thread preetika tyagi
@Arpit - Can you please explain how would you solve it using binary search? On Wed, Mar 2, 2011 at 10:41 PM, Arpit Sood wrote: > O(logn) binary search if there are no duplicates, else O(n) > > > On Thu, Mar 3, 2011 at 11:04 AM, Param10k wrote: > >> There is a sorted array and you have to write

Re: [algogeeks] sort partially sorted linked list

2011-03-02 Thread Ashish Goel
find two consecutive sequences(can be two increasing2I, 1i1d,1d1i,2D), merge them and then merge every next sequence with this merged sequence Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Mar 2, 2011 at 8:33 PM, Shreyas VA wrote: > I t

Re: [algogeeks] Amazon Question

2011-03-02 Thread Arpit Sood
O(logn) binary search if there are no duplicates, else O(n) On Thu, Mar 3, 2011 at 11:04 AM, Param10k wrote: > There is a sorted array and you have to write a fn to find a number in > the array which satisfies > > A[i] = i ; where A is the array and i is the index... > > - Param > http://teknotr

[algogeeks] Amazon Question

2011-03-02 Thread Param10k
There is a sorted array and you have to write a fn to find a number in the array which satisfies A[i] = i ; where A is the array and i is the index... - Param http://teknotron-param.blogspot.com/ -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gro

[algogeeks] Re: Water, Jug & Thinking Out of Box..Puzzle

2011-03-02 Thread Param10k
Hey Sandeep, Try doing it on your own. Thats how you can develop ur coding skills.. If you still need it, try http://geeksforgeeks.org/ Al d best.. -Param http://teknotron-param.blogspot.com/ On Mar 2, 12:36 pm, SANDEEP AAMIN wrote: > help me to find post order traversal of tree if preorder a

[algogeeks] Re: Water, Jug & Thinking Out of Box..Puzzle

2011-03-02 Thread Param10k
why to waste too much of water?? Follow these: /* Initially 3quart jug and 5quart jug are empty */ 1. Fill 5 quart jug /* Now 3quart jug is empty and 5quart jug is full */ 2. Pour water from 5quart jug into empty 3quart jug. /* Now 3quart jug is full and 5quart jug has 2quart remaining in it */ 3.

[algogeeks] Re: Tough Problem of Probability ..Surely Will Stuck ..So Think More & More

2011-03-02 Thread Don
Game 2 is better if p > 0.5. P(win game 1) = p P(win game 2) = p^3 + 3(p^2 * (1-p)) To find the solution, solve for p when p^3 + 3(p^2 * (1-p)) > p Which simplifies to 3p - 2p^2 > 1 Which is true when p > 0.5 On Mar 1, 5:15 pm, bittu wrote: > You have a basketball hoop and someone says that

Re: [algogeeks] Re: Tough Problem of Probability ..Surely Will Stuck ..So Think More & More

2011-03-02 Thread jagannath prasad das
@rajesgeeks:i think probability of sucess of 2nd game is 2(x^2(1-x))+x^2 becoz as explained below: 1.HH...so success in 2 shots no need of 3rd one 2.HFH 3.FHH where H-hit the hoop. F-failed to hit the hoop. On Wed, Mar 2, 2011 at 7:20 PM, rajessge...@yahoo.com wrote: > let p be the

Re: [algogeeks] Re: An interesting question

2011-03-02 Thread Kunal Patil
Nice explanation n nice code... On Sun, Feb 27, 2011 at 8:38 PM, gaurav gupta <1989.gau...@googlemail.com>wrote: > @pacific in your case a[0][0] might be wrong. So lets do this : > > a[0][0] = a[0][0 to n-1] & a[1 to n-1][0] // & of all elements in first > row and first column > > for( int i=1;

[algogeeks] Re: 2march

2011-03-02 Thread Don
Did he get frostbite on his toes? On Mar 2, 1:54 am, Lavesh Rawat wrote: > *WalK The River Problem Solution* > * > *A whole village crowded together at the edge of the lake, they all came for > a common purpose. > To see the man who could walk on water. > Many bets were placed, many a dreamer ima

[algogeeks] Re: Maze & labyrinth Solve Puzzle & WAP Efficiently

2011-03-02 Thread Don
class coord { public: int x; int y; }; class SolveMaze { public: SolveMaze() { location.x = location.y = 0; } bool Explore(); private: list visited; coord location; }; bool Explore() { // Determine if we've already been here if (visited.found(location)) return false; // Bas

Re: [algogeeks] Re: Meetings puzzle

2011-03-02 Thread Ashish Goel
How is E(s2) is calculated? Why E(S2)+1 Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Feb 9, 2011 at 5:05 PM, Ujjwal Raj wrote: > Input: n meetings > A meeting e(i) has start time s(i) and finish time f(i). > Sort n events based on there

[algogeeks] Maze & labyrinth Solve Puzzle & WAP Efficiently

2011-03-02 Thread bittu
You are in a maze(like a labyrinth), and you open your eyes so you don't know your position. The maze has walls and you can move only in up, right, left and down directions. You can escape the maze when you find a ladder. The following API is given: bool TryMove(direction) - returns true when you

Re: [algogeeks] sort partially sorted linked list

2011-03-02 Thread Shreyas VA
I think in this case bubble sort with early exit will be efficient On Wed, Mar 2, 2011 at 8:16 PM, snehal jain wrote: > The LL is in alternating ascending and descendin orders. Sort the list > efficiently > egs: 1->2->3->12->11->2->10->6->NULL > > -- > You received this message because you are s

[algogeeks] sort partially sorted linked list

2011-03-02 Thread snehal jain
The LL is in alternating ascending and descendin orders. Sort the list efficiently egs: 1->2->3->12->11->2->10->6->NULL -- 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 unsubs

[algogeeks] Re: Tough Problem of Probability ..Surely Will Stuck ..So Think More & More

2011-03-02 Thread rajessge...@yahoo.com
let p be the probability second game success probability is 3*[x^2(1-x)]+x^2 first game success probability is x find for which x ,3*[x^2(1-x)]+x^2x,this case game2 preffreed On Mar 2, 4:15 am, bittu wrote: > You have a basketball hoop and someone says that you can play 1 of 2 > games. > Ga

[algogeeks] Re: Robot Moving on The Maze..Need All possible Path

2011-03-02 Thread Dave
@Ashish: My answer is not the same as Catalan numbers. They obey (2*N) choose N - (2*N) choose (N+1), which is less than my answer. Dave On Mar 2, 6:55 am, Ashish Goel wrote: > Dave's answer is also same as catalan number, i donot understand why the > problem is different from catalan number sun

[algogeeks] Re: printing without loop

2011-03-02 Thread Sachin Midha
The method that I have given you, can print as many numbers as you want, depending upon how many objects you create. Yes with this method you'll have to create 100 objects of the dummy class, & that can be easily created using dummy d[100] So that makes the method very effective & shows how muc

Re: [algogeeks] Robot Moving on The Maze..Need All possible Path

2011-03-02 Thread sunny agrawal
in catalan number case you can not move above diagonal here we can by moving first only downwards then only left, one of the possible path that is not counted in catalan On Wed, Mar 2, 2011 at 6:25 PM, Ashish Goel wrote: > Dave's answer is also same as catalan number, i donot understand why the

Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-03-02 Thread Himanshu Sachdeva
ui nextsmallest( ui n) { ui x; int ctr=-1; x= (n&~(n-1)); // the lowest bit set in 'n' while( x&n)// finds the number of consecutive bits set from the lowest one { x<<=1; ctr++; } n^=x; n&=(~(x-1)); n+=(1

[algogeeks] impliment cin : MS question

2011-03-02 Thread Ashish Goel
can it be done without use of a goto? remember that the user can use backspace to remove the previous entered string...eg...before pressing enter, the user enters abcdef so the string is abdef How to decide how much buffer is optimum and would use of realloc be a good strategy? Also, i have a ve

Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-03-02 Thread Himanshu Sachdeva
#include typedef unsigned int ui; ui nextsmallest( ui n) { ui x; int ctr=-1; x= (n&~(n-1)); // the lowest bit set in 'n' while( x&n)// finds the number of consecutive bits set from the lowest one { x<<=1; ctr++; } n^=x; n&=(~(x-1)); x=1;

Re: [algogeeks] Robot Moving on The Maze..Need All possible Path

2011-03-02 Thread Ashish Goel
Dave's answer is also same as catalan number, i donot understand why the problem is different from catalan number sunny... Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Mar 2, 2011 at 3:03 PM, sunny agrawal wrote: > @ashish > its not tha

Re: [algogeeks] Search element in 2D row-wise colum-wise sorted matrix

2011-03-02 Thread Kunal Patil
Very Nice answer Sunny !!! On Wed, Mar 2, 2011 at 10:26 AM, sunny agrawal wrote: > step 1: start at Bottom-left corner > > step 2: if equal then return else if element is less than number to be > searched for then it cannot be in that row go up > step 3: if element is greater than number to b

Re: [algogeeks] Robot Moving on The Maze..Need All possible Path

2011-03-02 Thread sunny agrawal
@ashish its not that problem, read the question carefully On Wed, Mar 2, 2011 at 2:32 PM, Ashish Goel wrote: > refer catalan numbers > > Best Regards > Ashish Goel > "Think positive and find fuel in failure" > +919985813081 > +919966006652 > > > On Wed, Mar 2, 2011 at 2:00 AM, bittu wrote: > >>

Re: [algogeeks] Robot Moving on The Maze..Need All possible Path

2011-03-02 Thread Ashish Goel
refer catalan numbers Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Wed, Mar 2, 2011 at 2:00 AM, bittu wrote: > Imagine a robot sitting on the upper left hand corner of an NxN grid. > The robot can only move in two directions: right and down.

Re: [algogeeks] Bit Magic ....Always Stuck ..

2011-03-02 Thread MANNU
@bittu: is there any limit for the no. of zeroes in the next largest? -- 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+un