Re: [algogeeks] MS Question

2013-01-22 Thread Amitesh Singh
you can't implement in O(log n). It can be done in O(log n) in case of Ranked BS Tree. -- Amitesh On Sun, Jan 20, 2013 at 6:23 PM, Praveen praveensonare...@gmail.com wrote: If for all the nodes in BST we also store the size of subtree, then it is possible to find nth smallest element in

[algogeeks] Tree - sum problem

2012-11-17 Thread Amitesh Singh
Given a binary search tree and a target value, find all the paths (if there exists more than one) which sum up to the target value. It can be any path in the tree. It doesn't have to be from the root. -- Amitesh --

[algogeeks] inplace_merge() implementation

2012-10-11 Thread Amitesh Singh
Hi, Just wondering if anybody know the implementation of inplace_merge() defined in C++/STL (algorithm ? Source: http://www.cplusplus.com/reference/algorithm/inplace_merge/ Thanks -- Amitesh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] inplace_merge() implementation

2012-10-11 Thread Amitesh Singh
of elements, inplace_merge() alters the existing ranges to perform the merge in-place. --- cppreference.com On Thu, Oct 11, 2012 at 4:02 PM, Amitesh Singh singh.amit...@gmail.comwrote: Hi, Just wondering if anybody know the implementation of inplace_merge() defined in C++/STL (algorithm

Re: [algogeeks] Re: puzzle

2012-08-12 Thread Amitesh Singh
Does the pattern comes in this way? HT,TH,TT or HT(X)TH(X)TT ?? Let me know. -- Amitesh On Sat, Aug 11, 2012 at 11:24 PM, Piyush pkjee2...@gmail.com wrote: How can I find the expected number of tosses , required to obtain a {HT,TH,TT} , by using random variables?? On Friday, December

Re: [algogeeks] Re: puzzle

2012-08-12 Thread Amitesh Singh
time to do that for you. Please help yourself. Thanks -- Amitesh Singh On Sun, Aug 12, 2012 at 10:32 PM, Amitesh Singh singh.amit...@gmail.comwrote: Does the pattern comes in this way? HT,TH,TT or HT(X)TH(X)TT ?? Let me know. -- Amitesh On Sat, Aug 11, 2012 at 11:24 PM, Piyush

Re: [algogeeks] Inorder Iterative code for printing paths

2012-06-28 Thread Amitesh Singh
void printPath(node *p,node *child) { if( p child) std::cout Path: p-data =child-data std::endl; } use this before you assign 'current' to its children. e.g. printPath(p,p-left) or printPath(p,p-right); -- Amitesh On Mon, Jun 25, 2012 at 11:34 PM, Nishant

Re: [algogeeks] Inorder Iterative code for printing paths

2012-06-28 Thread Amitesh Singh
, 2012 at 11:01 AM, Amitesh Singh singh.amit...@gmail.comwrote: void printPath(node *p,node *child) { if( p child) std::cout Path: p-data =child-data std::endl; } use this before you assign 'current' to its children. e.g. printPath(p,p-left) or printPath(p

Re: [algogeeks] Question asked in Tachyon interview

2012-06-27 Thread Amitesh Singh
It can be done using Queues in O(n). -- Amitesh On Wed, Jun 27, 2012 at 3:07 PM, hary rathor harry.rat...@gmail.com wrote: apply BFS -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Adobe interview question

2012-06-22 Thread Amitesh Singh
It can done using pure virtual destructor. struct A { //your implementation .. .. .. virtual ~A() = 0; }; A::~A() { } -- Amitesh On Fri, Jun 22, 2012 at 1:44 PM, himanshu kansal himanshukansal...@gmail.com wrote: How will u implement an abstract class in c++ w/o using

Re: [algogeeks] Adobe interview question

2012-06-22 Thread Amitesh Singh
a pure virtual function does not have definition. Since pure virtual destructor has a definition so its only for not allowing the object instantiation, although it does not have any other abstract functions. -- Amitesh On Fri, Jun 22, 2012 at 1:51 PM, Amitesh Singh singh.amit

Re: [algogeeks] Double Linked List Represented With Single Linked List

2012-06-21 Thread Amitesh Singh
Krishna, how can you store a address pointing to k bits value into k/2 bits? XOR is the way to do this. -- Amitesh On Thu, Jun 21, 2012 at 1:20 AM, Krishna Kishore kknarenkris...@gmail.comwrote: *np *is nothing but *next_pointer. np[x] *does mean *x-np *which is the next pointer to

Re: [algogeeks] Analysis of Partial Sorting.

2012-06-18 Thread Amitesh Singh
Thanks Hassan. But I was more interested in knowing the mathematic proof of Partial Quick Sort. -- Amitesh On Sun, Jun 17, 2012 at 7:54 PM, Hassan Monfared hmonfa...@gmail.comwrote: O(N*logM) On Sat, Jun 16, 2012 at 5:15 PM, Amitesh Singh singh.amit...@gmail.comwrote: Hi Guys

Re: [algogeeks] Microsoft question

2012-06-17 Thread Amitesh Singh
check out this: RANDOMIZED-SELECT in O(n): http://amiteshsingh.wordpress.com/2012/06/08/iterative-randomized-select/ -- Amitesh On Sun, Jun 17, 2012 at 1:24 PM, Ashish Goel ashg...@gmail.com wrote: is the modification of the given array allowed? if yes use quick select, otherwise build

Re: [algogeeks] expectation values..

2012-06-16 Thread Amitesh Singh
This problem is similar to Coupan collector problem. http://en.wikipedia.org/wiki/Coupon_collector%27s_problem In your case the answer is [image: For N-Dice ; \newline \sum_{i=1}^{N} N/i \newline for\; N =~2 ; \newline \sum_{i=1}^{2} 2/i = 2/1 + 2/2 = 3 \newline] Hope it helps! -- Amitesh

[algogeeks] Analysis of Partial Sorting.

2012-06-16 Thread Amitesh Singh
Hi Guys, *Problem: *Rearrange a given array with n elements, so that m places contain the m smallest elements in ascending order. *Solution 2:* using QuickSort method approach. [image: n = r -p + 1] [image: \bold{PARTIAL-QUICKSORT(A,p,r,m)}: \newline if\; pr \newline q \leftarrow

Re: [algogeeks] expectation values..

2012-06-16 Thread Amitesh Singh
just curious to know if this question is asked in any interviews? Google interview? -- Amitesh On Sun, Jun 17, 2012 at 12:09 AM, Amitesh Singh singh.amit...@gmail.comwrote: This problem is similar to Coupan collector problem. http://en.wikipedia.org/wiki/Coupon_collector%27s_problem

Re: [algogeeks] Adobe interiew question

2012-06-13 Thread Amitesh Singh
signals and logjmp/setjmp() -- Amitesh On Wed, Jun 13, 2012 at 10:40 AM, saurabh singh saurab...@gmail.com wrote: tHE first thing that comes in my mind Signals Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Tue, Jun 12, 2012 at 10:26 PM,