Re: [algogeeks] Re: i cannot solve this written test question

2011-11-08 Thread sagar sindwani
if ( ten's place is != 9) Decrement the unit place by 1 and increment the ten's place by 1. else Increment MSD(Most significant digit) by 1 and decrement next digit by 1. example:- 712 721 897 987 On Sun, Oct 9, 2011 at 6:51 PM, wujin chen wujinchen...@gmail.com wrote: @Navneet,

Re: [algogeeks] Re: Median of 2D matrix

2011-11-08 Thread sagar sindwani
Use K-Median theorem with k=N On Mon, Nov 7, 2011 at 11:33 PM, Gene gene.ress...@gmail.com wrote: Can you explain how a heap helps get the answer? Just to put the elements in a heap requires O ( N^2 log (N) ) time. On Nov 7, 4:12 pm, vikas vikas.rastogi2...@gmail.com wrote: I think the

Re: [algogeeks] Re: Maximize Subsquare

2011-11-08 Thread Chunyuan Ge
Say you define ur matrix in M then if (M(i,j) = 1) Sq(i,j) = min(Sq(i-1,j),Sq(i-1,j-1),Sq(i, j-1)) + 1 else Sq(i,j) = 0 On Tue, Nov 8, 2011 at 7:27 AM, vikas vikas.rastogi2...@gmail.com wrote: try this: sq(i, j)= k is maximum sqare possible ending at i, j and has length k in the

[algogeeks] Does anyone know the written pattern of Amazon??

2011-11-08 Thread kumar raja
-- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] median from continuous stream

2011-11-08 Thread Arun Vishwanathan
Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand it...could someone please explain with a small example or so ?? thanks! -- People often say that motivation doesn't last. Well, neither does

Re: [algogeeks] Re: Binary tree to BST

2011-11-08 Thread surender sanke
unlink each node in original tree in postorder, and insert these nodes in new bst tree surender On Tue, Nov 8, 2011 at 4:48 AM, vikas vikas.rastogi2...@gmail.com wrote: @ Above no need to have another array or nything binTreeToBST(node *root) { if(!root )return; node *newRoot;

Re: [algogeeks] Does anyone know the written pattern of Amazon??

2011-11-08 Thread rahul sharma
apti + technical + 3 prog (mainly linked list) On Tue, Nov 8, 2011 at 3:09 PM, kumar raja rajkumar.cs...@gmail.com wrote: -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] median from continuous stream

2011-11-08 Thread tech coder
using a max heap and min heap we can find the median On Tue, Nov 8, 2011 at 10:59 AM, Arun Vishwanathan aaron.nar...@gmail.comwrote: Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand

[algogeeks] Re: median from continuous stream

2011-11-08 Thread Anurag Gupta
read this http://www.geeksforgeeks.org/archives/14873 On Nov 8, 10:29 am, Arun Vishwanathan aaron.nar...@gmail.com wrote: Hi to find running median from a stream of random generated numbers I have heard of the 2 heap ( min and max heap ) solution but I fail to understand it...could someone

[algogeeks] Finding the indexes of a repeated element??

2011-11-08 Thread kumar raja
How to find the indexes of a repeated element in the sorted array in *log n*time.. e.g. a: 1 3 4 4 5 6 7 8 8 9 9 9 10 x=9 ouput is 10 and 12 (indexing from 1) -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in -- You received this message because you are

Re: [algogeeks] Re: Median of 2D matrix

2011-11-08 Thread Anup Ghatage
I googled around and couldn't find a good source for the K-Median Theorem. So, could you provide a good link? On Tue, Nov 8, 2011 at 2:55 PM, sagar sindwani sindwani.sa...@gmail.comwrote: Use K-Median theorem with k=N On Mon, Nov 7, 2011 at 11:33 PM, Gene gene.ress...@gmail.com wrote: Can

[algogeeks] Re: Median of 2D matrix

2011-11-08 Thread vikas
Gene, we are not creating heap here but using the sorted matrix as heap itself. so use same logic of removing items from heap , in this case you have either right/bottom to reconstruct the structure. removing N^2 /2 items will give you the median. On Nov 7, 11:03 pm, Gene gene.ress...@gmail.com

[algogeeks] Re: i cannot solve this written test question

2011-11-08 Thread dee
@sagar, your method is correct for three digits, but since the question says the length could be upto 1000, the MSD in those cases will change Eg. 23998 24997 and not 32998 So in your algo, MSD should be replaced by while moving away from tens, hundreds, thousands... and so on, the first

[algogeeks] About suffix trees and suffix arrays

2011-11-08 Thread kumar raja
I have studied about it ,but could not understand why their construction is in linear time and support so many operations with less time complexity. i am quite confused. suggest me some good resource to learn about them with proper proof of time complexity for each and every operation.. --

Re: [algogeeks] Finding the indexes of a repeated element??

2011-11-08 Thread Dipit Grover
Using binary search, first find the first occurrence of x. Using this first occurrence run another binary search to find the last occurrence of x. -- 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] Does anyone know the written pattern of Amazon??

2011-11-08 Thread kumar raja
Thanks rahul On 8 November 2011 03:32, rahul sharma rahul23111...@gmail.com wrote: apti + technical + 3 prog (mainly linked list) On Tue, Nov 8, 2011 at 3:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in --

Re: [algogeeks] About suffix trees and suffix arrays

2011-11-08 Thread Shreyas VA
Check out Ukkonen's algorithm. You can build a suffix tree in O(n). Good stuff. I would start there On Tue, Nov 8, 2011 at 10:41 PM, kumar raja rajkumar.cs...@gmail.comwrote: I have studied about it ,but could not understand why their construction is in linear time and support so many

Re: [algogeeks] Re: Median of 2D matrix

2011-11-08 Thread yq Zhang
Vikas, The cost of removing elements from the matrix is O(N) it self. So by removing N^2/2 elements, the complexity of your algo should be N^3. However there are well-known algo for median in O(N) time in this case O(N^2) *because there are N^2 elements. On Tue, Nov 8, 2011 at 6:58 AM, vikas

Re: [algogeeks] Finding the indexes of a repeated element??

2011-11-08 Thread PIYUSH MADAN
Suppose the array is not sorted and we have to find if an element has occurred earlier or not; and if yes, then remove it.what is the best achievable time and how? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.