-
March 12th, 2011, 09:39 PM
#1
Is it possible to have an infix expression in a Ternary Tree and above?
Hi All,
Is it possible to have an infix expression in a ternary tree?
I am asking this because in a binary tree the infix expression is defined as visiting the left of the root, then the root, after that the right of the root. But in a ternary tree since there are 3 child nodes for each root, when should the root node be visited in order to make it infix.
I dont know any practical use of such a tree but it is a question that was once asked in an interview. any information regarding this will be great.
-
March 13th, 2011, 05:30 AM
#2
Re: Is it possible to have an infix expression in a Ternary Tree and above?
Seems to me that a ternary tree could be used the same way as a binary tree is used - by, for example, ignoring the right-most child (keeping it NULL) of each node, and considering the left-most and middle children to be left child and right child in accordance.
Or am I not getting your question right ?
Regards,
Zachm
-
March 13th, 2011, 10:36 AM
#3
Re: Is it possible to have an infix expression in a Ternary Tree and above?
<quote>
Zachm Seems to me that a ternary tree could be used the same way as a binary tree is used - by, for example, ignoring the right-most child (keeping it NULL) of each node, and considering the left-most and middle children to be left child and right child in accordance.
Or am I not getting your question right ?
<quote>
That would be like using a binary tree itself... But i am talking about a ternary or any higher order tree where there are odd number of children as its nodes here...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|