CS301 – Data Structures
Lecture No. 27
___________________________________________________________________
Data Structures
Lecture No. 27
Reading Material
Data Structures and Algorithm Analysis in C++
Chapter. 4
4.3
Summary
•
Properties of Binary Tree
•
Threaded Binary Trees
•
Adding Threads During Insert
•
Where is Inorder Successor?
•
Inorder Traversal
Properties of Binary Tree
By the end of the last lecture, we were having a discussion about the properties of the
binary trees. Let us recall, that I told you about a property of the binary trees regarding
relationship between internal nodes and external nodes i.e. If the number of internal
nodes is N, the number of external nodes will be N+1. Today I am going to discuss
another property of the binary trees, which together with the previous lecture, will give us
a start into a new topic. Let me have your attention to the second property of the binary
trees.
Property
A binary tree with N internal nodes has 2N links, N-1 links to internal nodes and N+1
links to external nodes.
Please recall that the first property dealt with the relationship between internal and
external nodes. This property is dealing with the relationship of links to the internal
nodes.
Now, what is a link? As you might already have understood, a link is that line, which we
draw between two nodes in a tree. Internally we use pointers in C++ to realize links. In
pictorial sketches, however, we use a line to show a link between the two nodes. The
property defines, that if you have a binary tree with Nodes, how many links, it will have
between the internal nodes (remember, it includes the leaf nodes), and how many links it
will have between the external nodes. We have not been showing any links between the
external nodes in the diagrams. These are, in fact, null pointers. That means, these are the
links, which we will show with the help of the square nodes. Let us see a binary tree, on
the basis of which, we will further explore this property. In the following figure, the
Page 1 of 14