A binary tree can be used to sort n elements of an array data. First, create a complete binary tree, a tree with all leaves at one level, whose height h = ⎡lg n⎤ + 1, and store all elements of the array in the first n leaves. In each empty leaf, store an element E greater than any element in the array. Figure 1a shows an example for data = {8, 20, 41, 7, 2}, h = ⎡lg(5)⎤ + 1 = 4, and E = 42. Then, starting from the bottom of the tree, assign to each node the minimum of its two children values, as in Figure 1b, so that the smallest element emin in the tree is assigned to the root. Next, until the element E is assigned to the root, execute a loop that in each iteration stores E in the leaf, with the value of emin, and that, also starting from the bottom, assigns to each node the minimum of its two children. Figure 1c displays this tree after one iteration of the loop.
Figure 1 Binary tree used for sorting.

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.