In this problem, you will be given a list of numbers. You have to sort the list using the Merge Sort algorithm. Pseudocode of Merge Sort Algorithm: def merge(a, b): def mergesort (arr): if len(arr) <= 1: return arr #write your code here #Here a and b are two sorted list #merge function will return a sorted list after merging a and b else: mid = len(arr)//2 al mergesort(.. a2 mergesort(.. return merge(a1, a2) Input The first line contains an integer N ( 1 <= N <10), denoting the length of Alice's sorted list. In the next line, there will be N integers separated by space. 8 Output: You have to sort the number using the Merge Sort algorithm and show the sorted list. Sample Input/Output: Sample Input 1 95461329 Sample Input 2 1 10 7 Sample Input 3 6 81 4 2 1 3 Sample Input 4 # write the parameter #write the parameter # complete the merge function above 7654321 Sample Output 1 1 2 3 4 5 6 9 9 Sample Output 2 10 Sample Output 3 1 1 2 3 4 8 Sample Output 4 1 2 3 4 5 6 7

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

solve this problem using python 

In this problem, you will be given a list of numbers. You have to sort
the list using the Merge Sort algorithm.
Pseudocode of Merge Sort Algorithm:
def merge(a, b):
# write your code here
# Here a and b are two sorted list
# merge function will return a sorted list after merging a and b
def mergesort (arr):
if len(arr) <= 1:
return arr
else:
mid= len(arr)//2
a1 = mergesort(..
a2 = mergesort (......
return merge(a1, a2)
Input
The first line contains an integer N ( 1 <= N <= 10³), denoting the
length of Alice's sorted list. In the next line, there will be N
integers separated by space.
Output:
You have to sort the number using the Merge Sort algorithm and show the
sorted list.
Sample Input/Output:
Sample Input 1
8
9 5 4 6 1 3 29
Sample Input 2
1
10
Sample Input 3
# write the parameter
# write the parameter
# complete the merge function above
6
8 1 4 2 1 3
Sample Input 4
7
7 6 5 4 3 2 1
Sample Output 1
1 2 3 4 5 6 99
Sample Output 2
10
Sample Output 3
1 1 2 3 4 8
Sample Output 4
1 2 3 4 5 6 7
Transcribed Image Text:In this problem, you will be given a list of numbers. You have to sort the list using the Merge Sort algorithm. Pseudocode of Merge Sort Algorithm: def merge(a, b): # write your code here # Here a and b are two sorted list # merge function will return a sorted list after merging a and b def mergesort (arr): if len(arr) <= 1: return arr else: mid= len(arr)//2 a1 = mergesort(.. a2 = mergesort (...... return merge(a1, a2) Input The first line contains an integer N ( 1 <= N <= 10³), denoting the length of Alice's sorted list. In the next line, there will be N integers separated by space. Output: You have to sort the number using the Merge Sort algorithm and show the sorted list. Sample Input/Output: Sample Input 1 8 9 5 4 6 1 3 29 Sample Input 2 1 10 Sample Input 3 # write the parameter # write the parameter # complete the merge function above 6 8 1 4 2 1 3 Sample Input 4 7 7 6 5 4 3 2 1 Sample Output 1 1 2 3 4 5 6 99 Sample Output 2 10 Sample Output 3 1 1 2 3 4 8 Sample Output 4 1 2 3 4 5 6 7
Expert Solution
steps

Step by step

Solved in 4 steps with 5 images

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