Docsity

Practice Problems for Test 2 - Computing for Engineers | CS 1371, Exams of Computer Science

Toggle sidebar
bg1
CS1371 Test 2 16 October 2003
Problem 1 (25 points total)
Show ALL of the steps when Merge-sort and Quick-sort are used to sort the
following array:
[6 4 1 3 9 7 5]
Quick
[4 1 3 5] [6] [9 7]
[1 3] [4] [5] [6] [7] [9]
[1] [3] [4] [5] [6] [7] [9]
[1 3 4 5 6 7 9]
Merge
[ 6 4 1 3] [9 7 5]
[6 4] [1 3] [9 7] [5]
[6] [4] [1] [3] [9] [7] [5]
[4 6] [1 3] [7 9] [5]
[1 3 4 6] [5 7 9]
[ 1 3 4 5 6 7 9]
Problem 2 (25 points total)
Write a script that will perform the following tasks:
pf3
pf4

Partial preview of the text

Download Practice Problems for Test 2 - Computing for Engineers | CS 1371 and more Exams Computer Science in PDF only on Docsity!

Problem 1 (25 points total) Show ALL of the steps when Merge-sort and Quick-sort are used to sort the following array:

[6 4 1 3 9 7 5]

Quick [4 1 3 5] [6] [9 7] [1 3] [4] [5] [6] [7] [9] [1] [3] [4] [5] [6] [7] [9] [1 3 4 5 6 7 9] Merge [ 6 4 1 3] [9 7 5] [6 4] [1 3] [9 7] [5] [6] [4] [1] [3] [9] [7] [5] [4 6] [1 3] [7 9] [5] [1 3 4 6] [5 7 9] [ 1 3 4 5 6 7 9] 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. x=0:.1:(2pi); y=0:.1:(2pi); [xx, yy]=meshgrid(x,y); zz= ((xx.^2 + sin(xx.yy))./(42.(xx.^2)+ eps)); mesh(xx,yy,zz); xlabel('x-axis'); ylabel('y-axis'); zlabel('z-axis'); 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 Page 2 of 4

Problem 4 (20 points total) Insertion Sort Page 4 of 4