Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- SOURABH
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.comwrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.comwrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.com wrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@googlegroups.com.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.com wrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.com wrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.comwrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.comwrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.com wrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.comwrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.comwrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.comwrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+unsubscr...@googlegroups.com. For
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar pareek: thanks On Sun, Jul 17, 2011 at 6:50 PM, sagar pareek sagarpar...@gmail.com wrote: yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.com wrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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] Microsoft Qn: Algo to find the border of a binary tree
can anyone pls tell me how to print 2D array in spiral manner?/ On 7/17/11, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: thanks On Sun, Jul 17, 2011 at 6:50 PM, sagar pareek sagarpar...@gmail.com wrote: yeah it can be On Sun, Jul 17, 2011 at 6:47 PM, prasanth n nprasnt...@gmail.com wrote: @sagar pareek: we cant use linked list ah?? On Sun, Jul 17, 2011 at 6:44 PM, sagar pareek sagarpar...@gmail.comwrote: kk... On Sun, Jul 17, 2011 at 5:31 PM, sourabh jakhar sourabhjak...@gmail.com wrote: @sagar pareek if you are from mnnit than donot disclose these kind of things here . On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @prasanth Trie will be used... :) :) On Sun, Jul 17, 2011 at 5:28 PM, sagar pareek sagarpar...@gmail.comwrote: @saurabh Ok... on 20th amazon is coming :) On Sun, Jul 17, 2011 at 4:35 PM, prasanth n nprasnt...@gmail.comwrote: @sourabh jakhar: how to design that big int class?? what data structure to use?? On Sun, Jul 17, 2011 at 3:55 PM, sourabh jakhar sourabhjak...@gmail.com wrote: i donot know abt the results but one thing for sure get your basic first right and than do the weird question On Sun, Jul 17, 2011 at 3:53 PM, sagar pareek sagarpar...@gmail.com wrote: Yeah best of luck saurabh whaen results will be out? On Sun, Jul 17, 2011 at 3:47 PM, sourabh jakhar sourabhjak...@gmail.com wrote: hey today ms visited our campus they asked simple 10 c output in first round and than 45 minutes coding round one question on test case on notepad,design bigint class,one simple question on array. On Sun, Jul 17, 2011 at 3:42 PM, sagar pareek sagarpar...@gmail.com wrote: @reynaled :- Happy to help @Sameer :- Thanks for pointing out and i think all you guyz now can optimize it :) On Sun, Jul 17, 2011 at 11:35 AM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: The question says Algo should be in place. So use of an array to print the right border of tree is not advisable. We can do it recursively without using an array also . On Sat, Jul 16, 2011 at 10:48 PM, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: @sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.com wrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.com wrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.com wrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.com wrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- You received this message because
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
according to saagar's algo, it'll be printed ... On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
yup :) On Sun, Jul 17, 2011 at 1:03 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: according to saagar's algo, it'll be printed ... On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
Sagar , Shubam Maheshwari Thanks!! On Sun, Jul 17, 2011 at 1:11 AM, sagar pareek sagarpar...@gmail.com wrote: yup :) On Sun, Jul 17, 2011 at 1:03 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: according to saagar's algo, it'll be printed ... On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
A pre-order traversal which is used to index the (min,max) pair value at each level except the bottom-most level where all the entries are to be printed. O(n) time O(log n) memory. On 7/17/11, swetha rahul swetharahu...@gmail.com wrote: Sagar , Shubam Maheshwari Thanks!! On Sun, Jul 17, 2011 at 1:11 AM, sagar pareek sagarpar...@gmail.com wrote: yup :) On Sun, Jul 17, 2011 at 1:03 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: according to saagar's algo, it'll be printed ... On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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 algogeeks@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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
Sagar;s Algo works, thank you so much guys. On Sun, Jul 17, 2011 at 3:41 AM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: A pre-order traversal which is used to index the (min,max) pair value at each level except the bottom-most level where all the entries are to be printed. O(n) time O(log n) memory. On 7/17/11, swetha rahul swetharahu...@gmail.com wrote: Sagar , Shubam Maheshwari Thanks!! On Sun, Jul 17, 2011 at 1:11 AM, sagar pareek sagarpar...@gmail.com wrote: yup :) On Sun, Jul 17, 2011 at 1:03 AM, Shubham Maheshwari shubham.veloc...@gmail.com wrote: according to saagar's algo, it'll be printed ... On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Shubham Maheshwari ShubZz O.o o.O enJoY ...!!! -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+unsubscr...@googlegroups.com.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.com wrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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.
Re: [algogeeks] Microsoft Qn: Algo to find the border of a binary tree
@sagar: There is one flaw in the code. Trace ur code 15 and 250 get printed twice. otherwise it is fine. On Sat, Jul 16, 2011 at 7:59 PM, sukhmeet singh sukhmeet2...@gmail.comwrote: please explain the code a bit more.. unable to understand it..an example will be better.. On Sun, Jul 17, 2011 at 7:10 AM, Reynald Suz reynaldsus...@gmail.comwrote: Yep! On Sun, Jul 17, 2011 at 1:02 AM, swetha rahul swetharahu...@gmail.comwrote: @Reynald Will 75 not be included in the tree that u have given..?? On Sun, Jul 17, 2011 at 12:49 AM, sagar pareek sagarpar...@gmail.comwrote: here is the code void border(node*); void recur(node*); void border(node *ptr) { node* tmp; int stack[20],top=0; if(tmp=ptr-left) { while(tmp-left) { printf(%d ,tmp-data); tmp=tmp-left; } } recur(ptr); if(tmp=ptr-right) { while(tmp-right) { stack[top++]=tmp-data; tmp=tmp-right; } } while(top--) printf(%d ,stack[top]); printf(%d\n,ptr-data); } void recur(node* ptr) { if(ptr-left) recur(ptr-left); if(!ptr-left!ptr-right) printf(%d ,ptr-data); if(ptr-right) recur(ptr-right); } On Sat, Jul 16, 2011 at 7:07 PM, Reynald reynaldsus...@gmail.comwrote: Algo to find the border of a given binary tree. Optimized for space and time. Input: 10 / \ 50 50 / \ / \ 25 75 20020 / \ / /\ 15 35 120155 250 Output:50 25 15 35 120 155 250 20 150 10 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- 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+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 algogeeks@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. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- 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+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 algogeeks@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 algogeeks@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.