[algogeeks] Re: tree from linked list

2010-05-16 Thread Ralph Boland
On May 14, 9:46 pm, Yalla Sridhar sridhar2...@gmail.com wrote: @atul linked list can be converted to array with O(n) both space @ time overhead. then tree can be built in O(n) This is true but is not the simplest solution. As pointed out earlier by me and also Divya Jain the best solution is

[algogeeks] Re: frequency

2010-05-16 Thread Modeling Expert
@sharad : Can you explain with same 'amazon' example for key mapping. if we have O(K) hash map, how would we map keys as We need to 'remember' mapping to print things back . e.g. ASCII valueof (C1)% sizeof(string) could be equal to valueof(C2)%sizeof(string) where strins is C1C2... @divya your

Re: [algogeeks] k the smallest in BST without using static variable

2010-05-16 Thread satwik krishna
@Rohit Can u pass on thje link of morris inorder On 5/15/10, Rohit Saraf rohit.kumar.sa...@gmail.com wrote: there is something called morris inorder traversal. credits to donald knuth On 5/15/10, kaushik sur kaushik@gmail.com wrote: Hi Friends I have encountered the question in

Re: [algogeeks] k the smallest in BST without using static variable

2010-05-16 Thread kaushik sur
Thanks Rohit! On Sat, May 15, 2010 at 7:13 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: there is something called morris inorder traversal. credits to donald knuth On 5/15/10, kaushik sur kaushik@gmail.com wrote: Hi Friends I have encountered the question in sites - Given a

[algogeeks] Re: BST

2010-05-16 Thread Modeling Expert
@Divya I think your solution is correct. To do in constant time , we can use BST itself instead of storing in array. Have two array , make first point to left most , make second point to right most member, now start your algorithm while making these two pointers move. Left pointer should move in

Re: [algogeeks] Re: frequency

2010-05-16 Thread sharad kumar
@Modelling expert. #includeiostream #includemap #includestring using namespace std; int main() { string s=amazon; int i=0,j=0; mapchar,intmp; for(i=0;is.length();++i) { mp[s.at(i)]++; }

Re: [algogeeks] tree question

2010-05-16 Thread sharad kumar
will your code work for tree attached and for sum =40?? On Fri, May 14, 2010 at 11:44 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: Strategy: subtract the node value from the sum when recurring down, and check to see if the remaining sum is 0 when you run out of tree. let sum be

Re: [algogeeks] Re: frequency

2010-05-16 Thread Sathaiah Dontula
@ALL, Here order of the string is preserved, if we use hash or bst, how you preserve the string order ?. Do you search again for each char ? @jalaj, do we need to give importance to order or not ? amazon = a2m1z1o1n1 Thanks, Sathaiah On Sun, May 16, 2010 at 5:40 PM, sharad kumar

Re: [algogeeks] Re: median of a bst

2010-05-16 Thread Sathaiah Dontula
would it be possible to come with the abstract solution with the following idea. 1. Use the inorder traversal, (we know this it prints elements in ascending order) 2. Use the same inorder traversal (inorder_rev) with the left, right change,( this will print in descending order) 3. Can we use this

Re: [algogeeks] string question

2010-05-16 Thread sharad kumar
suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of characters lets call it Sbig. Then there is a small set of characters lets call it Ssmall. You have to find

Re: [algogeeks] string question

2010-05-16 Thread divya jain
output ll be : e's On 16 May 2010 20:17, sharad kumar aryansmit3...@gmail.com wrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of characters

Re: [algogeeks] string question

2010-05-16 Thread Navin Naidu
use dp to solve this. On Sun, May 16, 2010 at 8:17 PM, sharad kumar aryansmit3...@gmail.comwrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On Sun, May 16, 2010 at 8:12 PM, divya sweetdivya@gmail.com wrote: You r given a large string of

Re: [algogeeks] string question

2010-05-16 Thread sharad kumar
@navin naidu like LCS in CLRS??? On Sun, May 16, 2010 at 8:20 PM, divya jain sweetdivya@gmail.comwrote: output ll be : e's On 16 May 2010 20:17, sharad kumar aryansmit3...@gmail.com wrote: suppose if i give Ssmall:es Sbig:he's a algogeek and he's rocking wat will be o/p? On

Re: [algogeeks] string question

2010-05-16 Thread Rohit Saraf
@Navin: and that works ! :) @all : i am sure no heuristic/greedy strategy can be applied. @divya : did you check your array partitioning algorithm with my example ! -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering

Re: [algogeeks] tree question

2010-05-16 Thread Rohit Saraf
Either the root will be included or it will not be. If it's not, then it's equivalent to solving the problem on the subtrees. So let's consider the case when root node is included Now we keep track of A[node1,node2,reqdWeight] reqdWeight is the sum of wt reqd from paths starting from node1 and

Re: [algogeeks] question

2010-05-16 Thread Rohit Saraf
@anurag : won't work -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] regarding DSW algortihm

2010-05-16 Thread Rohit Saraf
Read it up : http://www.eecs.umich.edu/~qstout/pap/CACM86.pdf -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay http://www.cse.iitb.ac.in/~rohitfeb14 -- You received this message because you are

Re: [algogeeks] Re: median of a bst

2010-05-16 Thread Rohit Saraf
@Nikhil : For that size of subtrees at all nodes needs to be maintained. And in that case this is a trivial problem. @Sathaiah : See my solution :) -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and Engineering IIT Bombay

[algogeeks] Re: frequency

2010-05-16 Thread Modeling Expert
@sharad : Thanx !! But is it really O(K) ? if you use mapchar,int for say AMAZON you need 5 (chars) + ( 5*4) ( ints) = 25 bytes. + some more space due to MAP structure One more char and you are crossing 26 bytes solution provided by Jalaj. Think about storing Allodoxaphobia A= 3 , L = 2 O = 3 , D

[algogeeks] Re: BST

2010-05-16 Thread Modeling Expert
sorry , there was a typo 'Have two array read it as Have two pointers -Manish On May 16, 1:04 pm, Modeling Expert cs.modelingexp...@gmail.com wrote: @Divya I think your solution is correct. To do in constant time , we can use BST itself instead of storing in array. Have two array , make

Re: [algogeeks] question

2010-05-16 Thread Navin Naidu
@anurag: wont work, consider the following case: -99 0 2 -1 99 On Sun, May 16, 2010 at 9:12 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @anurag : won't work -- Rohit Saraf Second Year Undergraduate, Dept. of Computer Science and

Re: [algogeeks] string question

2010-05-16 Thread Navin Naidu
@Sharad: yup On Sun, May 16, 2010 at 8:36 PM, Rohit Saraf rohit.kumar.sa...@gmail.comwrote: @Navin: and that works ! :) @all : i am sure no heuristic/greedy strategy can be applied. @divya : did you check your array partitioning algorithm with my example !

[algogeeks] Convert BST to any other BST

2010-05-16 Thread Sathaiah Dontula
How many ROTATIONS are required to convert any n-node BST to convert to any other n-node BST ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group,