sec13 - CS100M Section Exercise 13 1 Merge Sort a=[4 1 6 3...

• Lab Report
• 2

This preview shows pages 1–2. Sign up to view the full content.

CS100M Section Exercise 13 1 Merge Sort The code for MergeSort and the function header for Merge are shown below. Trace the execution of the script a= [4 1 6 3 2 9 5 7 6 0]; b= MergeSort(a); For each call of the MergeSort and Merge , write down the arguments that are passed to the function and the values that are returned. The code below displays the values in vectors y1 and y2 and they are the values returned by specific calls to MergeSort . Notice that multiple instances of the same function may be open at one time—which function has this behavior, MergeSort or Merge ? Ask your section instructor if you have any questions! function y = MergeSort(x) % x is a column n-vector. % y is a column n-vector consisting of the values in x sorted % from smallest to largest. n = length(x); if n==1 y = x; else m = floor(n/2); % Sort the first half.. y1 = MergeSort(x(1:m)) % values displayed are the values returned by this call of MergeSort % Sort the second half...

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Summer '07
• FAN/VANLOAN

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern