Trees 291
A simulation of the above algorithm for the following treeList is given in Figure 7.16.
treeList[] = {‘A’, ‘(‘, ‘B’, ‘(‘, ‘D’,’(‘,’H’, ‘I’,’)’, ‘E’,’(‘, ‘J’,’$’, ‘)
’,’)’,’C’,’(‘,’F’,’(‘,’K’,’L’,’)’,’G’,’)’,’)’,’#’};
Fig. 7.16 The creation of binary tree using the algorithm createBinTree()
It may be noted that the algorithm developed by us has created exactly the same tree which is shown
in Figure 7.15.
7.4.3 Traversal of Binary Trees
A binary tree is traversed for many purposes such as for searching a particular node, for processing some ...