Hi, is it possible to construct a pre oder binary tree?
i know how to do a pre order traversal. but constructing a binary tree using that i am not sure what it mean?
what is the purpose of doing a pre order construction of binary treE??
please advise
how do i construct a preordered binary tree?
Page 1 of 13 Replies  1983 Views  Last Post: 23 March 2010  10:19 AM
Replies To: how do i construct a preordered binary tree?
#2
Re: how do i construct a preordered binary tree?
Posted 23 March 2010  09:09 AM
What do you mean by a preorder binary tree? When you are building the tree you are building it in order so you are going to have to explain what you actually mean.
#3
Re: how do i construct a preordered binary tree?
Posted 23 March 2010  09:12 AM
Martyn.Rae, on 23 March 2010  08:09 AM, said:
What do you mean by a preorder binary tree? When you are building the tree you are building it in order so you are going to have to explain what you actually mean.
Ok. my assigment below:
(Binary Tree Traversals) Suppose you have a binary tree T containing only distinct
items. The preorder sequence of T is 8, 7, 5, 28, 4, 9, 18, 17, 16, and the inorder
sequence of T is 5, 7, 4, 28, 9, 8, 18, 16, and 17.
Suggest an algorithm to construct binary tree out of preorder and inorder
sequence. (note: hard question)
i am quite lost with the question too.
please advise how i can start?
cause i also duno wat the question is about
#4
Re: how do i construct a preordered binary tree?
Posted 23 March 2010  10:19 AM
I think I understand what is required for this assignment. You need to think about the order in which you could transverse a tree recursively. Preorder is root, then left then right for each node. So in pseudo code:
1. Consider this node
2. Call self with the left hand node
3. Call self with right hand node
Inorder is left node then root and then right node. So in pseudo code that would be
1. Call self with the left hand node
2. Consider this node
3. Call self with right hand node
Hope that helps you
1. Consider this node
2. Call self with the left hand node
3. Call self with right hand node
Inorder is left node then root and then right node. So in pseudo code that would be
1. Call self with the left hand node
2. Consider this node
3. Call self with right hand node
Hope that helps you
Page 1 of 1
