Repeat Exercise 7.2.1 when the initial order of the numbers is 1,3,5,7,9,2,4,6,8. Exercise 7.2.1 Suppose that the program of Fig. 7.2 uses a partition function that always picks a[m] as the separator...


Repeat Exercise 7.2.1 when the initial order of the numbers is 1,3,5,7,9,2,4,6,8.


Exercise 7.2.1


Suppose that the program of Fig. 7.2 uses a partition function that always picks a[m] as the separator v. Also, when the array a[m],... ,a[n] is reordered, assume that the order is preserved as much as possible. That is, first come all the elements less than v, in their original order, then all elements equal to v, and finally all elements greater than v, in their original order.


a) Draw the activation tree when the numbers 9,8,7,6,5,4,3,2, 1 are sorted.


b) What is the largest number of activation records that ever appear together on the stack?


Fig. 7.2



May 22, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here