Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
a Sort the arrayboxes using the QuickSort algorithm a default implementation is not stablethe sortin...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started