i. In Block 2 Part 6, you saw that selection sort requires about (n-1)²/2 comparisons to sort a list of length n. In fact, the exact number of comparisons required by selection sort to sort a list of length n is nx (n-1)/2. Use this formula to calculate the total number of comparisons required to sort two lists each of length 100. ii. Once the two lists have been sorted, they need to be merged. Suggest a reason why the maximum number of comparisons required to merge two lists, each of length 100, is 199. iii. Hence, find the maximum total number of comparisons required to sort two lists of length 100 using Strategy B.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter16: Searching, Sorting And Vector Type
Section: Chapter Questions
Problem 16SA
icon
Related questions
Question
i. In Block 2 Part 6, you saw that selection sort requires about (n-1)²/2
comparisons to sort a list of length n. In fact, the exact number of comparisons
required by selection sort to sort a list of length n is nx (n-1)/ 2. Use this formula
to calculate the total number of comparisons required to sort two lists each of
length 100.
ii. Once the two lists have been sorted, they need to be merged. Suggest a reason
why the maximum number of comparisons required to merge two lists, each of
length 100, is 199.
iii. Hence, find the maximum total number of comparisons required to sort two lists of
length 100 using Strategy B.
Transcribed Image Text:i. In Block 2 Part 6, you saw that selection sort requires about (n-1)²/2 comparisons to sort a list of length n. In fact, the exact number of comparisons required by selection sort to sort a list of length n is nx (n-1)/ 2. Use this formula to calculate the total number of comparisons required to sort two lists each of length 100. ii. Once the two lists have been sorted, they need to be merged. Suggest a reason why the maximum number of comparisons required to merge two lists, each of length 100, is 199. iii. Hence, find the maximum total number of comparisons required to sort two lists of length 100 using Strategy B.
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Quicksort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning