Consider the Sort-and-Count algorithm explained in section 5.3 of our text: "Counting Inversions"Suppose that the initial list is: 92   71   36   91   27   48   14   34   81   26   24   65   78   51   37   22 Sort-and-Count makes two recursive calls. The first recursive call inputs the first half of the initial list: 92   71   36   91   27   48   14   34 and returns the sorted version of the first half, as well as the number of inversions found in the first half (22). The second recursive call inputs the second half of the initial list: 81   26   24   65   78   51   37   22 and returns the sorted version of the second half, as well as the number of inversions found in the second half (19). Sort-and-Count then calls Merge-and-Count. To Merge-and-Count, Sort-and-Count passes the sorted versions of the two halves of the original list: 14   27   34   36   48   71   91   92, and 22   24   26   37   51   65   78   81 Merge-and-Count begins merging the two half-lists together, while counting inversions. 14   27   34   36   48   71   91   92      22   24   26   37   51   65   78   81   14   22   24   26   27   34   36   37   48   51   65   71   78   81   91   92       7    7    7                   4         3    3         2    2     (inversions) The inversions counted during the merge are shown in the last line above. The total number of inversions counted between the two sorted halves is7+7+7+4+3+3+2+2 = 35.Therefore the total number of inversions in the original list is 22+19+35 = 76.YOUR ASSIGMENT:Do the same work as above, except starting with this initial list: 26   81   87   32   66   72   86   97   23   48   14   71   89   18   49   62

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Consider the Sort-and-Count algorithm explained in section 5.3 of our text: "Counting Inversions"

Suppose that the initial list is:

92   71   36   91   27   48   14   34   81   26   24   65   78   51   37   22

Sort-and-Count makes two recursive calls. The first recursive call inputs the first half of the initial list:

92   71   36   91   27   48   14   34

and returns the sorted version of the first half, as well as the number of inversions found in the first half (22). The second recursive call inputs the second half of the initial list:

81   26   24   65   78   51   37   22

and returns the sorted version of the second half, as well as the number of inversions found in the second half (19). Sort-and-Count then calls Merge-and-Count. To Merge-and-Count, Sort-and-Count passes the sorted versions of the two halves of the original list:

14   27   34   36   48   71   91   92, and

22   24   26   37   51   65   78   81

Merge-and-Count begins merging the two half-lists together, while counting inversions.

14   27   34   36   48   71   91   92      22   24   26   37   51   65   78   81

 

14   22   24   26   27   34   36   37   48   51   65   71   78   81   91   92

      7    7    7                   4         3    3         2    2     (inversions)

The inversions counted during the merge are shown in the last line above. The total number of inversions counted between the two sorted halves is

7+7+7+4+3+3+2+2 = 35.

Therefore the total number of inversions in the original list is 

22+19+35 = 76.

YOUR ASSIGMENT:

Do the same work as above, except starting with this initial list:

26   81   87   32   66   72   86   97   23   48   14   71   89   18   49   62

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps with 5 images

Blurred answer
Knowledge Booster
Computational Systems
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education