Mark Honetschlager
SIES 610
Data Structures Assignment
1. Which numbers will require comparisons during a binary search for the number ‘7’ in the
following list? 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11
Answer: 6 -> 9 -> (7 & 8)
2. Which numbers will require comparisons a linear for the number 7 in the following list? 1,2 3, 4,
5, 6, 7,8,9,10,11? What other way you could do a linear search on this list?
Answer: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7, This linear search can be done in the other direction from
greatest to least
3. Consider the following numbers: 3, 7, 9, 2, 5
a. Put the numbers into a stack. Now remove them one by one. Write down the order they
come out.
Answer: (In) 3 -> 7 -> 9 -> 2 -> 5
(Out) 5 -> 2 -> 9 -> 7 -> 3
b. Put the numbers into a queue. Now remove them one by one. Write the order they
come out.
Answer: (In) 3 -> 7 -> 9 -> 2 -> 5
(Out) 3 -> 7 -> 9 -> 2 -> 5
c. Show the steps to quick sort the numbers, considering 3 is the pivot.
i. 3, 7, 9, 2, 5
ii. 2, 3, 7, 9, 5 (Everything to left of 3 is now sorted)
iii. 2, 3, 7, 9, 5 (Selecting 7 as new pivot)
iv. 2, 3, 5, 7, 9 (Everything to the right of 3 is now sorted. List sorting complete)
d. Show the steps to bubble sort the numbers.
i. 3, 7, 9, 2, 5
ii. 3, 7, 9, 2, 5
iii. 3, 7, 9, 2, 5 (swap)
iv. 3, 7, 2, 9, 5 (swap)
v. 3, 7, 2, 5, 9
vi. 3, 7, 2, 5, 9 (swap)
vii. 3, 2, 7, 5, 9 (swap)
viii. 3, 2, 5, 7, 9 (swap)
ix. 2, 3, 5, 7, 9
x. 2, 3, 5, 7, 9
xi. 2, 3, 5, 7, 9
e. Show the steps to selection sort the numbers.
i. 3, 7, 9, 2, 5 (start)
ii. 2, 3, 7, 9, 5 (move 2)
iii. 2, 3, 7, 9, 5
iv. 2, 3, 5, 7, 9 (move 5)
v. 2, 3, 5, 7, 9
vi. 2, 3, 5, 7, 9