CS302 Midterm Exam - October 13, 2015 - Page Three


Question 4

You are sorting the following vector of integers:

{ 10, 47, 99, 64, 77, 35, 56, 21 }

Selection: Suppose you run selection sort on this vector. From the choices below, circle all of the lines of output that will be printed, if you print the vector after each pass of selection sort. You don't have to worry about the order in which the lines are printed -- just circle the letters that correspond to the lines that are printed.

Insertion: Suppose you run insertion sort on this vector. From the choices below, circle all of the lines of output that will be printed, if you print the vector after each pass of insertion sort.

Note -- these choices are sorted lexicographically, so that you can find the ones you want easily.

a.  10  21  35  47  56  64  77  99
b.  10  21  35  47  56  64  99  77
c.  10  21  35  47  56  99  64  77
d.  10  21  35  47  56  99  77  64
e.  10  21  35  47  77  99  56  64
f.  10  21  35  47  99  64  77  56
g.  10  21  35  64  77  99  56  47
h.  10  21  47  77  64  35  99  56
i.  10  21  47  99  64  77  35  56
j.  10  21  99  64  77  35  56  47
k.  10  35  21  47  56  64  77  99
l.  10  35  47  21  56  64  77  99
m.  10  35  47  56  21  64  77  99
n.  10  35  47  56  64  77  99  21
o.  10  35  47  64  77  99  56  21
p.  10  35  56  64  77  99  47  21
q.  10  47  35  56  21  64  77  99
r.  10  47  35  56  64  21  77  99
s.  10  47  64  35  56  21  77  99
t.  10  47  64  77  35  56  21  99
u.  10  47  64  77  99  35  56  21
v.  10  47  64  99  77  35  56  21
w.  10  47  99  64  77  35  56  21
x.  10  56  77  47  99  64  35  21
y.  10  77  99  47  56  35  64  21
z.  10  99  56  35  21  77  64  47