Question: Construct the binary tree. Output the root value. The elements a_1, a_2,...,a_n are the leaves of the tree, and we build up the tree one

Construct the binary tree. Output the root value. The elements a_1, a_2,...,a_n are the leaves of the tree, and we build up the tree one level at a time from there. From left to right, compare the elements in pairs, and put the larger of the two as the parent vertex. Do this at each level until reaching the root, which will be the largest element. Output the value at the root. For example, if the list to be sorted is 22, 8, 14, 17, 3, 9, 27, 11, the tree would look like? this: In the second step, remove the leaf corresponding to that largest element, and replace it with a leaf labeled 0, which is defined to be smaller than all the other list elements. Recompute the labels of all vertices on the path from this 0 to the root. That is, relabel all vertices on the path from the 0 to the root by choosing the larger of the values of their two children. Then the root will become the second-largest element. Output the value at the root. In our example, the tree would now look like this: Steps 3 through ns Recompute labels. Output the root value. Repeat the same process as described in step 2. At the end, we will have output the entire list in decreasing order. Trace through the algorithm as applied to the list 17, 4, 1, 5, 13, 10, 14, 6. Show the tree at each step. If n is a power of two, as in the example, how many comparisons are done at step 1? How many comparisons are done in each of the other steps? If n is a power of two, as in the example, how many comparisons are done throughout the entire algorithm? What is the order of the algorithm in Theta notation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
