0

I have a question about the traversal of a tree.

When we print the values of a binary search tree using in order traversal are the values printed in an ascending order??

Mary Star
  • 375
  • 7
  • 27

1 Answers1

0

Yes, the normal implementation of a binary search tree is in ascending order, i.e. nodes to the left are smaller than nodes to the right.

As the concepts of "left" and "right" are what we specify, and "lower" and "higher" depend on what the keys really represent, it's of course possible to implement the tree as a descending tree (or just a reverse traversal). In that case you might want to add "reverse" or "descending" to the name of the tree to signify the uncommon implementation.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
  • So, when we traverse the tree using the in-order traversal and print the keys, they will be in ascending order, right?? – Mary Star Dec 19 '14 at 12:02
  • @MaryStar: Yes, you can find a description of the in-order traversal here: http://en.wikipedia.org/wiki/Tree_traversal – Guffa Dec 19 '14 at 16:06