Suppose merge sort algorithm is run on the following vector: 5, 301, 101, 100, 102, 302, 1 Which of the following is the correct sorted output (ascending)? a. 1, 5, 102, 101, 301, 302, 100 b. 1, 5, 101, 102, 302, 301, 100 c. 1, 5, 101, 102, 301, 302, 100 d. 1, 5, 301, 302, 101, 102, 100

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

Suppose merge sort algorithm is run on the following vector:
5, 301, 101, 100, 102, 302, 1
Which of the following is the correct sorted output (ascending)?
a. 1, 5, 102, 101, 301, 302, 100
b. 1, 5, 101, 102, 302, 301, 100
c. 1, 5, 101, 102, 301, 302, 100
d. 1, 5, 301, 302, 101, 102, 100

Expert Solution
Step 1

- The question wants to have the correct output for merge sort in ascending order.

 

- Here we have merge sort algorithm working on the given vector which is to be sorted in ascending order.

- The algorithm sorts the vector in ascending order using the divide and conquer methodology.

 

- The first option has 102 ahead of 101 which is not sorted, So, this option is incorrect.

- The second option has 302 ahead of 301 which is not sorted, So, this option is incorrect.

- The third option has 302 ahead of 100 which is not sorted, So, this option is incorrect.

- The fourth option has 302 ahead of 101 which is not sorted, So, this option is incorrect.

 

- The correct output should have been  1,5,100,101,102 ,301,302.

 

steps

Step by step

Solved in 2 steps

Blurred answer
Similar 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