Question: 1. For the following non-recursive implementation of QuickSort using a stack, Report in the table the maximum depth of the stack as well as the

1. For the following non-recursive implementation of QuickSort using a stack, Report in the table the maximum depth of the stack as well as the running time in -notation for the following cases a. i. A is sorted (i.e., in increasing order); ii. A with all elements equal; iii. A is reversely sorted (i.e., in decreasing order) b. If the order of the two push operations in the code is changed, explain the change to the table, if any QUICK-SORT (A, p, r) s -empty 2. PUSH (S, (p, r)) // (pxis a tuple, pushed as a single element 3. while S is not empty 4, do (p, r) -POP (S) S is the stack if p r then q-PARTITION(A, p, r) PUSH(S, (gt1, r) PIUSH (S, (p, q-1)) max. stack runningExplanations depth time e) e) A is sorted A with all elements el equal A is reversely sortedel e)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
