This preview shows page 1. Sign up to view the full content.
Unformatted text preview: right subtree, which by definition are greater than the value in the root. And we are then finished. Finished? But what about the values in the left and right subtrees? How do we print them? Why, the same way of course. They are, after all, just binary search trees. This algorithm sounds too easy. That’s the beauty of recursive algorithms: They are often short and elegant (though sometimes they take some thought to trace). Let’s write it and trace it, using the tree shown below the algorithm. We number the calls in our trace because there are two recursive calls. Print (tree) If (tree is NOT null) Print (left(tree)) Write info(tree) Print(right(tree))...
View Full Document
This note was uploaded on 01/13/2011 for the course CSE 1550 taught by Professor Marianakant during the Fall '10 term at York University.
- Fall '10