


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



Problem 1 (25 points total) Show ALL of the steps when Merge-sort and Quick-sort are used to sort the following array:
Problem 2 (25 points total) Write a script that will perform the following tasks: 1.) plot z = x^2 + sin(xy) from x = 0 to 2 * pi with. increments
42y^2 from y = 0 to 2 * pi with. increments *Make sure your plot is continuous use eps 2.) label your axes as “x-axis” , “y-axis”, “z-axis” appropriately. Problem 3 (30 points total) A "set" is a collection of items where there can be no duplicate items in the collection. For instance, the roles for this class are a set because no student will be enrolled twice. There are a variety of operations we can perform on sets. The "intersection" of two sets A and B is the set of items where each item is in both A and B. Page 2 of 4
Problem 4 (20 points total) Name the Sort Method? _______________ function b = mySort(a) b = []; i = 1; sz = length(a); while i <= sz pivot = a(1,i); b = helpSort(b, pivot ); i = i + 1; end b=b'; function b = helpSort(a, pivot) i = 1; sz = length(a); done = 0; while i <= sz if pivot < a(i,1) done = 1; j = sz + 1; while j > i a(j,1) = a(j-1); j = j - 1; end a(i,1) = pivot; i = sz + 1; else i = i + 1; end end if done == 0 a(sz+1,1) = pivot; end b = a; Page 4 of 4