[algogeeks] Re: BST Problem
@giri: can u post d correct answer?? -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: BST Problem
@giri: thnx frnd...sorry ppl . ignore my post :( -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: BST Problem
for the above post i have assumed that the two nodes whose sum is k is present in the BST... so correct me if m wrong -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: BST Problem
can v do like this??? findnodes(root,sum) { if(root==abs(sum-root->data)) print (the data is root->data, sum-(root->data)); else if(rootdata)) findnodes(root->right,sum-root->data) else if(root>abs(sum-root->data)) findnodes(root->left,sum-root->data) else if(root->left==NULL || root->right==NULL) print(root,sum-root); } -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Generate all bit strings of length n
hw abt this? start from right most bit.. if it is the right most bit and if its 0 then flip it and proceed to the prev. bit else flip the rightmost zero to 1 and invert the subsequent bits follow the above proc. till the left most bit is flipped to 1. correct me if m wrong!! -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Algorithm to find all subsets of size K
@raj really cool On Aug 22, 1:08 pm, Raj N wrote: > Generate all binary strings of length k. For eg: S={1,2,3,4,5} generate all > binary strings of length 5. 0 represents that particular number is absent > and 1 for the presence of the number. > > > > On Fri, Aug 13, 2010 at 11:35 PM, asdf wrote: > > Most efficient algorithm to find all subsets of size K?? > > > -- > > 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, send email to > > algogeeks+unsubscr...@googlegroups.com > .com> > > . > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: how to implement TAIL command of unix.
read the i/p file count the no. of '\n' characters if count > k (argument of tail) then print all chars till EOF correct me if m wrong !!! On Aug 16, 9:16 am, vikas kumar wrote: > the method of farword seek is inefficient. consider case of 10 > lines and you want to display only 3-4 lines. better seek from end. > > se a buffer[buf_size]. > > let size =filesize. > lc = 0; > while(lc <= given line input) > { > fseek(fp, size); > if(size < buf_size) > fread(fp, size, buffer); > else > fread(fp, size, buf_size); > > parse buf_size for '\n' > if( \n is in buffer ) > increment line counter(lc ++) > if(size < buf_size) > size -= buf_size > > } > > // you know the size, read the buffer one by one and print it > OR > // you could have put them while reading on to stack and print it out > now > > On Aug 15, 8:46 am, Dave wrote: > > > > > Enter the lines into a FIFO queue as you read them. After you have > > enqueued n lines, dequeue a line every time you enqueue one, so that > > the queue will contain the last n (or fewer) lines of the file. > > > Dave > > > On Aug 13, 1:13 pm, amit wrote: > > > > I am trying using fseek but somehow its not working?- Hide quoted text - > > > - Show quoted text - -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Alternative merge
link nt working...so can anyone explain fr new users?? On Aug 16, 6:52 pm, Minotauraus wrote: > Please check link. > > On Aug 15, 8:25 pm, Gene wrote: > > > > >http://groups.google.com/group/algogeeks/browse_thread/thread/f56bac6... > > > The best solution given there is O(n) with only constant additional > > storage. > > > On Aug 15, 1:51 pm, Debajyoti Sarma wrote: > > > > so what was the optimal solution found in the previous discussion?? give > > > a link > > > I don't remember the name of the thread...so only i posted this. > > > > On 8/15/10, Gene wrote: > > > > > In fact this solution was suggested (without code) in the original > > > > discussion. > > > > > It's O(n^2). > > > > > You're only re-ordering a constant number (4) of elements in each > > > > recursive pass, and each pass requires O(n) time to execute. You also > > > > need to assume your compiler will remove the tail recursion. > > > > Otherwise it will also require O(n) space, which misses the whole > > > > point of the problem. > > > > > On Aug 15, 12:29 pm, Debajyoti Sarma > > > > wrote: > > > >> Array of 2n length is given {a1,a2,a3,...,an,b1,b2,b3,...,bn} > > > >> we have to make the array like as {a1,b1,a2,b2,a3,b3,...,an,bn} > > > >> without using extra buffer space. > > > >> here a solution i came up withhttp://codepad.org/ub5Ie4sI > > > >> I know this was discussed before . > > > >> But i want to know the time complexity of the code i have given(i m > > > >> confused) > > > > > -- > > > > 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, send email to > > > > algogeeks+unsubscr...@googlegroups.com. > > > > For more options, visit this group at > > > >http://groups.google.com/group/algogeeks?hl=en. -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re:
can anyone post a good article on tries??? i am a newbie...so pls help!! On Aug 22, 11:26 am, Ukil wrote: > use suffix trie. > > On Aug 16, 9:36 pm, ashita dadlani wrote: > > > > > You have a string say "foobarfoo" in which "fo" and "oo" aree repeated > > twice.You have to find all such repeated pairs in O(n) time,The string can > > only have alphanumeric elements in it. -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Reading large numbers?
if the file is standard i/p then go for strings or linked list. On Aug 16, 10:44 am, janani thiru wrote: > How can I read a file which has 10^9 characters or more efficiently? > > -- > Janani T -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Time complexity - is anybody bothered about it anyway?
@asutosh:: all ur efforts 2 write some code wud be worthless if it cant work for some inputs...if it can , then no one does bother about time complexity. since it doesn for large i/ps v hav 2 write some efficient code (although i agree wid u dat its painful :P ) On Aug 17, 9:45 pm, Dave wrote: > For 30 years, I developed mathematical software (linear equation > solvers, eigenvalue routines, fast Fourier transforms, etc.) on a wide > variety of high-performance computers with interesting architectures. > For those, the optimal-order algorithms are well known. My principal > goal was to implement a variant of the best algorithm that made the > constant as small as possible. > > Dave > > On Aug 17, 8:24 am, Ashutosh Tamhankar wrote: > > > > > Greetings > > > How many of you guys calculate the time complexity of an algorithm > > before implementing it on a day to day basis? > > > When you review your code, before committing it to the live source > > code base, does anybody discuss the time complexity? > > > Would love to hear your interesting experiences.. > > > Regards > > Ashutosh -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: BFS
@manohar and @giri:: doesn recursion itself use stacks( implicitly)?? On Aug 18, 9:26 pm, Giri wrote: > @manohar: thnks man.. this solution would be apt.. > > if there's any better algo which doesn't use an extra stack or queue, > but does the purpose in recursion, do post it.. > > On Aug 18, 8:01 am, Manjunath Manohar > wrote: > > > > > Tree *node > > for(i=1;i<=height;i++) > > { > > levelorder(node,i);} > > > void levelorder(Tree *node,int level) > > { > > if(level==1) > > printf(node->value); > > else > > levelorder(node->left,level-1) > > levelorder(node->right,level-1); > > > } -- 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, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.