Question
Construct a binary tree from a hash Table using vectors. The hash Table should be a vector . Where vector is a vector of 3
Construct a binary tree from a hash Table using vectors. The hash Table should be a vector
Where vector
Next, vector
Finally, the hash table is the vector
0 1 2
1 3 4
....
9 -1 -1
The rst number is the parentnode ID, the second number is the left child node ID, the third number is the right childnode ID. For example, in the line of 0 1 2, the node 0 is the parent of node 1 and node 2,and node 1 is the left child of node 0, node 2 is the right child of node 2. If a node does nothave a left/right child, then the second/third number will be -1. For example, in the line of4 9 -1, the node 4 has only a left child (node 9) but has not a right child. In the line of 9 -1-1, the node 9 does not have a left or a right child.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started