Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this part, you will look at some further examples of how Strategy 2 performs compared to Strategy 1 . i . Merging two lists
In this part, you will look at some further examples of how Strategy performs compared to Strategy
iMerging two lists of length m and n respectively never needs more than m n comparisons.
This is because each comparison results in an item being moved to the merged list. If there are m n items altogether then if we ever got to m n comparisons it would mean we had moved all but one of the items to the merged list and the final item could be moved without any comparison.
This is the worst case; in general we are likely to need fewer than m n comparisons.
Suppose the first list contained items and the second list contained items.
How many comparisons would Strategy take to sort a combined list of items?
Considering Strategy what is the greatest number of comparisons it could take to bubble sort the first and second lists individually, then merge the results?
Comment briefly on the difference in performance.
iiIs Strategy always an improvement on Strategy Consider an extreme case. Suppose the first list has only item and the second list has items. Following the same method as in part i above, calculate the maximum number of comparisons required by each strategy and comment briefly on what you find.
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