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 && currentHeight<h1
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 && currentHeight<h2
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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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_7MJ<https://groups.google.com/d/msg/algogeeks/-/xjchdh2I_7MJ>.
>>
>> > > To post to this group, send email to [email protected].
>> > > To unsubscribe from this group, send email to
>> > > algogeeks+unsubscribe@**googlegroups.com<algogeeks%[email protected]>.
>>
>> > > For more options, visit this group at
>> > >http://groups.google.com/**group/algogeeks?hl=en<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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.