Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help, I'm lost... Suppose that we add a command to the MERGE procedure right before line 12 (see p. 31) asking whether L[11] (the

image text in transcribed

image text in transcribed

please help, I'm lost...

Suppose that we add a command to the MERGE procedure right before line 12 (see p. 31) asking whether L[11] (the last element of L before the sentinel) is smaller than R[1]. If that is the case, we know that the array consisting of the subarray L followed by the subarray R, is sorted in increasing order and no more comparisons are needed. Otherwise, if L[11]>R[1], the algorithm proceeds as before. Call this the "modified merge procedure" MMERGE and call MMERGE-SORT the procedure MERGE- SORT that uses MMERGE instead of MERGE. Suppose we run MMERGE-SORT on an array of length n which is already sorted. How many comparisons are needed? Is the running time for this sorted array better than the running time when using MERGE-SORT, Thetan ign) ? Explain using plain English. MERGE(A, p, q,r) 1 ni = q- p + 1 2 n = r-9 3 let L[1..ni + 1] and R[1..n2 + 1] be new arrays 4 for i = 1 to ni 5 L[i] = A[p + i - 1] 6 for j = 1 to n2 7 R[j] = A[q + j] 8 L[ni + 1] = 0 9 R[n2 + 1] = 0 10 i = 1 11 j = 1 12 for k = p tor 13 if L[i]

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

International Baccalaureate Computer Science HL And SL Option A Databases Part I Basic Concepts

Authors: H Sarah Shakibi PhD

1st Edition

1542457084, 978-1542457088

Students also viewed these Databases questions

Question

What is operatiing system?

Answered: 1 week ago

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago