Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Merge - Sort ( A , p , r ) if p > = r return q = floor ( ( p + r )

Merge-Sort(A, p, r)
if p >= r
return
q = floor((p + r)/2)
Merge-Sort (A, p, q)
Merge-Sort (A, q +1, r)
Merge(A, p, q, r)
MERGE (A, p, q, r)
1 n= q - p C 1
2 n= r - q
3 let L[1.. n+1] and R[1... n+1] be new arrays
4 for i =1 to n
5 L[i]= A[p + i -1]
6 for j =1 to n
7 R[j]= A[q + j]
8 L[n+1]= infinity
9 R[n+1]= infinity
10 i =1
11 j =1
12 for k = p to r
13 if L[i]< R[j]
14 A[k]= L[i]
15 i = i +1
16 else A[k]= R[j]
17 j = j +1
Let array A =<16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1>.
How many times do we execute line 13 to sort the above array A using a merge sort?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

2. Are you varying your pitch (to avoid being monotonous)?

Answered: 1 week ago

Question

3. Are you varying your speaking rate and volume?

Answered: 1 week ago