Question: Mina always wants things to be sorted. She loves perfection in work and doesn't worry about time. Her brother gifted her some boxes with

Mina always wants things to be sorted. She loves perfection in work

Mina always wants things to be sorted. She loves perfection in work and doesn't worry about time. Her brother gifted her some boxes with different sizes. Now she needs your help to sort it. You're given n boxes with different sizes and your task is to sort the boxes in ascending order of size. You should recursively partition the array with a number p so that all the elements greater than p are to its right and all the elements lower than p to its left to sort the boxes. Make sure you are giving a solution that doesn't exceed the time complexity of O(n^2), but on average has complexity of O(nlogn) a. Which algorithm will you suggest to Mina? Explain if your algorithm is stable or unstable with appropriate example [3] b. Show the step by step simulation of your algorithm on the boxes of size 5,9,10, 3, 15, 12, 6, 20, 9, 13, 3, 10, 1, 1. 2. [5] c. Give an example of box sizes when it will be worst case and when it will be the best case for this algorithm. [2]

Step by Step Solution

3.44 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a Sort the arrayboxes using the QuickSort algorithm a default implementation is not stablethe sortin... View full answer

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 Algorithms Questions!