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 =<12,23,45,31,52,37,81,47,39,27,62,36,33,42,54,44>.
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

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

How can the Internet be helpful in a job search? (Objective 2)

Answered: 1 week ago