When programming Binary Trees in a high level programming
language, we use an array of
records.
Each record consists of the data and two pointers
- A LEFT
pointer and a RIGHT
pointer.
Example :
Create a tree using the data
Johnson, Clay, Mullet, Ferry,
Zob, Lunt
Well, we already did that
in the previous task.......
The data would be stored as...
Node |
LEFT |
DATA |
RIGHT |
1 |
2 |
Johnson |
3 |
2 |
0 |
Clay |
4 |
3 |
6 |
Mullet |
5 |
4 |
0 |
Ferry |
0 |
5 |
0 |
Zob |
0 |
6 |
0 |
Lunt |
0 |
The pointers give the node numbers of the
left and right
child nodes.
|