cthan323
February 4th, 2008, 12:24 AM
In a binary tree, will the order that values are inserted always be the same as the preorder traversal?
For example, inserting ints in this order: 6 2 1 4 3 5 7
will produce a binary tree that has the same preorder traversal.
Could someone give me an example where this is not the case?
Thanks
EDIT: Nevermind. This was a dumb question. So here is another one. Can one construct a binary tree given only one of the preorder, postorder, orinorder traversals? Or are at least two traversals needed?
For example, inserting ints in this order: 6 2 1 4 3 5 7
will produce a binary tree that has the same preorder traversal.
Could someone give me an example where this is not the case?
Thanks
EDIT: Nevermind. This was a dumb question. So here is another one. Can one construct a binary tree given only one of the preorder, postorder, orinorder traversals? Or are at least two traversals needed?