Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MERGE.A; p; q; r / 1 nL D q p C 1 / / length of A p W q 2 nR D r q

MERGE.A; p; q; r/
1 nL D q p C 1// length of Ap W q
2 nR D r q // length of Aq C 1 W r
3 let L0 W nL 1 and R0 W nR 1 be new arrays
4 for i D 0 to nL 1// copy Ap W q into L0 W nL 1
5 Li D Ap C i
6 for j D 0 to nR 1// copy Aq C 1 W r into R0 W nR 1
7 Rj D Aq C j C 1
8 i D 0// i indexes the smallest remaining element in L
9 j D 0// j indexes the smallest remaining element in R
10 k D p // k indexes the location in A to ll
11// As long as each of the arrays L and R contains an unmerged element,
// copy the smallest unmerged element back into Ap W r.
12 while i < nL and j < nR
13 if Li Rj
14 Ak D Li
15 i D i C 1
16 else Ak D Rj
17 j D j C 1
18 k D k C 1
19// Having gone through one of L and R entirely, copy the
// remainder of the other to the end of Ap W r.
20 while i < nL
21 Ak D Li
22 i D i C 1
23 k D k C 1
24 while j < nR
25 Ak D Rj
26 j D j C 1
27 k D k C 1

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

Database And Expert Systems Applications 15th International Conference Dexa 2004 Zaragoza Spain August 30 September 3 2004 Proceedings Lncs 3180

Authors: Fernando Galindo ,Makoto Takizawa ,Roland Traunmuller

2004th Edition

3540229361, 978-3540229360

More Books

Students also viewed these Databases questions

Question

Describe the nature, development, and consequences of self-esteem.

Answered: 1 week ago

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago