Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this part, you will look at some further examples of how Strategy 2 performs compared to Strategy 1 . How many comparisons would Strategy

In this part, you will look at some further examples of how Strategy 2 performs compared to Strategy 1.
How many comparisons would Strategy 1 take to sort a combined list of 23 items?
Considering Strategy 2, 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.
i. Merging two lists of length m and n respectively never needs more than m + n 1 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 1 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 1 comparisons.
Suppose the first list contained 18 items and the second list contained 5 items.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago