[algogeeks] Re: Find border of a binary tree.
Good question. The problem is not well-defined. It's possible that 75 should be omitted because there are deeper subtrees to the left and right. But we'll never know for sure because examples don't make a good definition. On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote: i guess in the given link 1st example should inculde 75 ?? correect me if i am wrong. On Fri, Apr 6, 2012 at 10:53 PM, Doom duman...@gmail.com wrote: Here is the reference: http://stackoverflow.com/questions/3753928/finding-border-of-a-binary... None of the proposed solutions is effective enough. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ. 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.
[algogeeks] Re: Find border of a binary tree.
75 is omitted because its the border. Think of border like putting an elastic rubber band around the tree. Print the nodes being touched by the rubber. On Monday, 9 April 2012 08:12:48 UTC+5:30, Gene wrote: Good question. The problem is not well-defined. It's possible that 75 should be omitted because there are deeper subtrees to the left and right. But we'll never know for sure because examples don't make a good definition. On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote: i guess in the given link 1st example should inculde 75 ?? correect me if i am wrong. On Fri, Apr 6, 2012 at 10:53 PM, Doom duman...@gmail.com wrote: Here is the reference: http://stackoverflow.com/questions/3753928/finding-border-of-a-binary... None of the proposed solutions is effective enough. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ. 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 view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vCCkW93pMCgJ. 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] Re: Find border of a binary tree.
then one way to do this would be something like this :- find h1=maxHeight of root-left find h2=maxHeight of root-right leave root and first print left and right subtree of the root now call print(root-left) a) if root-left==NULL root-right!=NULL currentHeighth1 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node now call print(root-right) a) if root-right==NULL root-right!=NULL currentHeighth2 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node after calling both function above print root-data; On Mon, Apr 9, 2012 at 10:30 AM, Doom duman...@gmail.com wrote: 75 is omitted because its the border. Think of border like putting an elastic rubber band around the tree. Print the nodes being touched by the rubber. On Monday, 9 April 2012 08:12:48 UTC+5:30, Gene wrote: Good question. The problem is not well-defined. It's possible that 75 should be omitted because there are deeper subtrees to the left and right. But we'll never know for sure because examples don't make a good definition. On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote: i guess in the given link 1st example should inculde 75 ?? correect me if i am wrong. On Fri, Apr 6, 2012 at 10:53 PM, Doom duman...@gmail.com wrote: Here is the reference: http://stackoverflow.com/**questions/3753928/finding-** border-of-a-binary.http://stackoverflow.com/questions/3753928/finding-border-of-a-binary... None of the proposed solutions is effective enough. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/**msg/algogeeks/-/xjchdh2I_7MJhttps://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/**group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vCCkW93pMCgJ. 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] Re: Find border of a binary tree.
@above : correction in now call print(root-right) , highlighted below a) if root-right==NULL *root-left!=NULL* currentHeighth2 On Mon, Apr 9, 2012 at 10:53 AM, atul anand atul.87fri...@gmail.com wrote: then one way to do this would be something like this :- find h1=maxHeight of root-left find h2=maxHeight of root-right leave root and first print left and right subtree of the root now call print(root-left) a) if root-left==NULL root-right!=NULL currentHeighth1 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node now call print(root-right) a) if root-right==NULL root-right!=NULL currentHeighth2 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node after calling both function above print root-data; On Mon, Apr 9, 2012 at 10:30 AM, Doom duman...@gmail.com wrote: 75 is omitted because its the border. Think of border like putting an elastic rubber band around the tree. Print the nodes being touched by the rubber. On Monday, 9 April 2012 08:12:48 UTC+5:30, Gene wrote: Good question. The problem is not well-defined. It's possible that 75 should be omitted because there are deeper subtrees to the left and right. But we'll never know for sure because examples don't make a good definition. On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote: i guess in the given link 1st example should inculde 75 ?? correect me if i am wrong. On Fri, Apr 6, 2012 at 10:53 PM, Doom duman...@gmail.com wrote: Here is the reference: http://stackoverflow.com/**questions/3753928/finding-** border-of-a-binary.http://stackoverflow.com/questions/3753928/finding-border-of-a-binary... None of the proposed solutions is effective enough. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/**msg/algogeeks/-/xjchdh2I_7MJhttps://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/**group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vCCkW93pMCgJ. 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] Re: Find border of a binary tree.
above you need to print only those leaf nodes which are at height h1 or h2. actually some of the cases are missed in above algo.which would result in wrong output. i will post the solution , once taking into account of all cases. On Mon, Apr 9, 2012 at 10:56 AM, atul anand atul.87fri...@gmail.com wrote: @above : correction in now call print(root-right) , highlighted below a) if root-right==NULL *root-left!=NULL* currentHeighth2 On Mon, Apr 9, 2012 at 10:53 AM, atul anand atul.87fri...@gmail.comwrote: then one way to do this would be something like this :- find h1=maxHeight of root-left find h2=maxHeight of root-right leave root and first print left and right subtree of the root now call print(root-left) a) if root-left==NULL root-right!=NULL currentHeighth1 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node now call print(root-right) a) if root-right==NULL root-right!=NULL currentHeighth2 then print current node which is nothing but internal node. b) if root-left==NULL root-right==NULL // printing leaf node print node after calling both function above print root-data; On Mon, Apr 9, 2012 at 10:30 AM, Doom duman...@gmail.com wrote: 75 is omitted because its the border. Think of border like putting an elastic rubber band around the tree. Print the nodes being touched by the rubber. On Monday, 9 April 2012 08:12:48 UTC+5:30, Gene wrote: Good question. The problem is not well-defined. It's possible that 75 should be omitted because there are deeper subtrees to the left and right. But we'll never know for sure because examples don't make a good definition. On Apr 8, 2:29 pm, atul anand atul.87fri...@gmail.com wrote: i guess in the given link 1st example should inculde 75 ?? correect me if i am wrong. On Fri, Apr 6, 2012 at 10:53 PM, Doom duman...@gmail.com wrote: Here is the reference: http://stackoverflow.com/**questions/3753928/finding-** border-of-a-binary.http://stackoverflow.com/questions/3753928/finding-border-of-a-binary... None of the proposed solutions is effective enough. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/**msg/algogeeks/-/xjchdh2I_7MJhttps://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscribe@**googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/**group/algogeeks?hl=enhttp://groups.google.com/group/algogeeks?hl=en . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/vCCkW93pMCgJ. 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.