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 is a vector of 3 numbers with the first number being the parent node and the second number is the left child and the third number is the right child in the tree.

Next, vector> is the list of all 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!