Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 . ( 8 marks ) Quicksort can, in the worst circumstances ( owing to unwise choices of pivot values ) , perform as poorly
marks Quicksort can, in the worst circumstances owing to unwise choices of pivot values perform as poorly for large collections of data as exchange sort. It usually doesn't however, and is frequently described as having an average complexity that is proportional to
n logn
Thats n times the log of n log is described in this week's notes on binary search, as binary search has a time complexity proportional to logn Scientific calculators frequently have a way of calculating log of a number, and so does Microsoft Excel. I encourage you to use Excel or some compatible spreadsheet program Google Sheets, perhaps to help you with calculating these logarithms for this problem. For practice, open a new workbook in Excel, put the number into cell A and this formula, exactly as shown, into cell B:
loga
then press Enter. You should have caused a to appear in place of the formula in cell B is the log of which is usually written log and is also not coincidentally the number of zeroes in the binary for :
Let's repeat the exercise from the previous page, but this time using quicksort instead of exchange sort. For this first part, it will still be you sorting books, and you are still capable of one compareandswap operation per second on average, but now you'll be using n logn and rounding up to the nearest integer, instead of n n for your middle column calculations. Again, I've done the first one for you.
Number of items n Number of comparisons Sort time in minutes
and seconds mm:ss
:
Returning to our computer that can make one million comparisonandswap operations per second, on average. It is now using quicksort to sort one million items of data. How many days, hours, minutes, and seconds d hh:mm:ss will the computer require to do that?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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