[algogeeks] DP Help...

2011-10-05 Thread Vikram Singh
any one give a good link to study Dynamic Programming concepts?? --Regards Vikram -- 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] Array Problem??

2011-10-03 Thread Vikram Singh
Given an array say A=(4,3,1,2). An array B is formed out of this in such a way that B[i] = no. of elements in A, occuring on rhs of A[i], which are less then A[i]. eg.for the A given, B is (3,2,0,0). Here A of length n only contains elements from 1 to n that too distinct.. Now the problem is: 1).

Re: [algogeeks] Re: Array Problem??

2011-10-03 Thread Vikram Singh
The naivest solution is O(n2). Could you give a hint for this problem? On Oct 3, 4:39 pm, Vikram Singh singhvikram...@gmail.com wrote: Given an array say A=(4,3,1,2). An array B is formed out of this in such a way that B[i] = no. of elements in A, occuring on rhs of A[i], which are less then A[i

Re: [algogeeks] Re: Array Problem??

2011-10-03 Thread Vikram Singh
@anshu: pls elaborate... give an example... On Tue, Oct 4, 2011 at 9:51 AM, anshu mishra anshumishra6...@gmail.comwrote: use segment tree or binary index tree to solve O(nlogn) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Re: sqrt function...

2011-09-25 Thread Vikram Singh
ok.. thanks guys... one doubt now... if this ques is asked in an interview(its already been asked in ms interview)... then u cant just write the code... u hv to explain the whole approach like why u r choosing that way to narrowing dowm the range... so pls explain how this sol is derived... On

[algogeeks] sqrt function...

2011-09-24 Thread Vikram Singh
any one suggest an algo to write own sqrt func...?? -- 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] Re: MICROSOFT WRITTEN

2011-09-12 Thread Vikram Singh
how abt this: (i hv used some variables) a=x; b=-x; k1=a7; (if we assume 8 bit number) k2=b7; n=k1 | k2; n=n-1; k=n7; return (y-k*(y-z)); Explanation: if(x0 or x0) a and b are of opp signs, one of k1 and k2 is 0and other is 1... n=1; n becomes 0; k =0; y is returned if(x==0) a=b=0;

[algogeeks] Re: Microsoft written!!!

2011-09-06 Thread Vikram Singh
i m asking again, cos no one replied earlier: in example given by mohit... is the leftmost right cousin of 8 and 9, NULL or 12?? On Aug 27, 6:42 pm, aditi garg aditi.garg.6...@gmail.com wrote: This grp is full of MS interview ques..search the archives... On Sat, Aug 27, 2011 at 6:55 PM, teja

[algogeeks] Re: microsoft interview

2011-09-02 Thread Vikram Singh
how abt this: if(!a[0][0]) { first traverse the 1st row till we find any 1... On Sep 2, 12:32 pm, kranthi raj kranthi...@gmail.com wrote: oops missed Space Complexity On Fri, Sep 2, 2011 at 12:55 PM, kranthi raj kranthi...@gmail.com wrote: for( i = 0 ; i n ; ++i )    for( j = 0 ;

[algogeeks] Re: microsoft interview

2011-09-02 Thread Vikram Singh
how abt this: if(!a[0][0]) { first traverse the 1st row till we find 1. if dere is 1 do a[0][0]+=2; then traverse the first column till 1.. if dere is 1... do a[0][0]+=3; } apply dave's method if(a[0][0]==2) make 1st row 1 else if(a[0][0]==3)

[algogeeks] Re: Microsoft written!!!

2011-08-27 Thread Vikram Singh
in above example... is the leftmost right cousin of 8 and 9, NULL or 12?? On Aug 10, 4:36 pm, Brijesh Upadhyay brijeshupadhyay...@gmail.com wrote: thank u , i couldnot  have answered this :P -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

[algogeeks] inorder predecessor

2011-08-26 Thread Vikram Singh
i figured out algo to find the inorder predecessor of a bst without using parent pointer... just wanna confirm if its missing any case if the left child(subtree) of node exist, then predecessor ll be the max value in the left subtree. else predecessor ll be one of the ancestor in this

[algogeeks] Re: inorder predecessor

2011-08-26 Thread Vikram Singh
sukrandha...@gmail.com wrote: is it not possible to traverse tree in order and store in array. then figure out the element and print the previous element? On Fri, Aug 26, 2011 at 2:04 PM, Vikram Singh singhvikram...@gmail.comwrote: i figured out algo to find the inorder predecessor

[algogeeks] Re: inorder predecessor

2011-08-26 Thread Vikram Singh
; } } return parent; } } i hope it makes u understand@sanjay... On Aug 26, 5:27 pm, Sanjay Rajpal srn...@gmail.com wrote: Vikram : will u plz elaborate more on ur solution ? Sanju :) On Fri, Aug 26, 2011 at 5:24 AM, Vikram Singh singhvikram...@gmail.comwrote