Algorithms and Data Structures (INF1, Autumn'05)

Exercise Set 8


Exercise 1:

In this exercise the square (nil) nodes in a binary tree are not considered (counted) and the values stored in the nodes are irrelevant.
Exercise 2:

Let t be a binary tree.
Exercise 3 (hand-in):

Consider a binary tree at the very top of page 110 in the book.
Exercise 4 (hand-in):

Professor Konfus once claimed:

"inorder traversal of a binary tree always visits a leaf as the first node".

Was he right? If yes, prove his claim. If not, give a counter example.


Exercise 5:

What is the worst-case time complexity of preorder(t.root), inorder(t.root) and postorder(t.root) assuming that visit(x) takes