Here is the problem, just simply sorting an array. Now, to sort the array you should use efficient sorting techniques. It will have worst-case time complexity better than the above sorting algorithms. The sorting algorithm pseudocode is given below:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
need the correct solve asap plz. use python to solve it.
Task 4:
Here is the problem, just simply sorting an array. Now, to sort the array you should use
efficient sorting techniques. It will have worst-case time complexity better than the
above sorting algorithms. The sorting algorithm pseudocode is given below:
MERGE (A, p, q, r)
n1 +q - p + 1
n2 +r - q
Create arrays L[1.. n1 + 1] and R[1. . n2 + 1]
FOR i+1 to n1
DO L[i] + A[p + i - 1]
FOR j+1 to n2
DO R[j] + A[q + j]
L[n1 + 1]+ 00
R[n2 + 1]+ o
i+1
j+1
FOR k +p TOr
DO IF L[i]< R[j)
THEN A[k] + L[i]
iti + 1
ELSE A[k] + R[j]
j+j + 1
MERGE - SORT (A, p, r)
if p < r
// Check for base case
q = (p + r)/2
MERGE – SORT (A, p, q)
MERGE - SORT (A, q + 1, r)
MERGE (A, p, q, r)
Take help from pseudocode or use your way to complete the task.
First line will contain N. The next line will contain N number of elements. The output will
contain a sorted N number of elements (ascending order).
Input 2:
Input 1:
5
5-1 10 28
10 20 3 40 5 6
Output 1:
-1258 10
Output 2:
356 10 20 40
Transcribed Image Text:Task 4: Here is the problem, just simply sorting an array. Now, to sort the array you should use efficient sorting techniques. It will have worst-case time complexity better than the above sorting algorithms. The sorting algorithm pseudocode is given below: MERGE (A, p, q, r) n1 +q - p + 1 n2 +r - q Create arrays L[1.. n1 + 1] and R[1. . n2 + 1] FOR i+1 to n1 DO L[i] + A[p + i - 1] FOR j+1 to n2 DO R[j] + A[q + j] L[n1 + 1]+ 00 R[n2 + 1]+ o i+1 j+1 FOR k +p TOr DO IF L[i]< R[j) THEN A[k] + L[i] iti + 1 ELSE A[k] + R[j] j+j + 1 MERGE - SORT (A, p, r) if p < r // Check for base case q = (p + r)/2 MERGE – SORT (A, p, q) MERGE - SORT (A, q + 1, r) MERGE (A, p, q, r) Take help from pseudocode or use your way to complete the task. First line will contain N. The next line will contain N number of elements. The output will contain a sorted N number of elements (ascending order). Input 2: Input 1: 5 5-1 10 28 10 20 3 40 5 6 Output 1: -1258 10 Output 2: 356 10 20 40
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY