Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. (10 pts) Use figure 5 in the attached illustrations as a model to show the operations of the algorithm merge, used by merge sort

image text in transcribed

image text in transcribed

3. (10 pts) Use figure 5 in the attached illustrations as a model to show the operations of the algorithm merge, used by merge sort on (A, 0, 4,9), where A = {1, 6, 7,5, 0, 9, 8, 4, 3, 2}. Fig 5: Operation of merge on (numbers, 0, 4,9), where numbers = {0,2,4,5,7, 1, 3, 6, 8, 9} and array indices start with 0. Initial values: leftPos = 0, rightPos = 5, mergePos = 0 numbers: mergeNumbers: 0|2|4|5|7|1|3 | 6 | 8 | 9 012|4|5|7| 1 3 61 82 After Iteration 1: leftPos = 1, rightPos = 5, mergePos = 1 numbers: mergeNumbers: 012 4 571 36 89 012 4 57131689 After Iteration 2: leftPos = 1, rightPos = 6, mergePos = 2 numbers: mergeNumbers: 012 4 571 36 | 8 9 After Iteration 3: leftPos = 2, rightPos = 6, mergePos = 3 numbers: mergeNumbers: 0 2 4 57 13 6891 0 1 2 5 7 1 3 689 After Iteration 4: leftPos = 2, rightPos = 7, mergePos = 4 numbers: mergeNumbers: 0121457131689 10 1 2 3 713 689| After Iteration 5: leftPos = 3, rightPos = 7, mergePos = 5 numbers: mergeNumbers: 0|1|2|3|4|1|3 | 6 | 819 After Iteration 6: leftPos = 4, rightPos = 7, mergePos = 6 numbers: mergeNumbers: 0 | 2 | 4 | 5 | 7 | 1 | 3 | 6 | 8 | 9 | 1 | 2 | 3 | 4 | 5 | 5 | 6 | 8 | 9 After Iteration 7: leftPos = 4, rightPos = 8, mergePos = 7 numbers: mergeNumbers: 5 1616891 After Iteration 8: leftPos = 5, rightPos = 8, mergePos = 8. The main loop ends here. numbers: mergeNumbers: P12145711 | 3 | 6 | 8191 After the rest of merge is executed: leftPos = 5, rightPos = 10, mergePos = 10 numbers: mergeNumbers

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

3. What are the current trends in computer hardware platforms?

Answered: 1 week ago