 
Summary: University of Wuppertal
Faculty C  Department of Mathematics
Dr. Holger Arndt, Dipl.Math. Sigrid Fischer
Algorithms and Data Structures
WS 2004/2005
Exercise Sheet 3
Exercise 8 (4 p.) In the web you will find a program bst.c with data types and operations
for a binary search tree.
a) Write a function bs tree bs max(bs tree t) that returns the pointer pointing at
the maximal key. Analyse the time complexity in dependence on the height h
of nodes of the tree.
b) Write a function int bs height(bs tree t) that returns the height of the binary
search tree. Analyse the time complexity in dependence on the number n of
nodes of the tree.
c) Modify the program bst.c to test your functions from a) and b) as follows
create a new tree
insert the numbers 6, 4, 8, 2, 12, 7, 10, 5 one after the other
delete the data set with key 6
delete the entry with the maximal key
Display the maximal key, the height and the complete tree after every change.
