logo

UTK Notes


Clicker Questions - 12-Bud-Sel-Ins

Since you just learned these algorithms, let me summarize each pass of the first three sorting algorithms:

  • Bubble: Each pass: If element $i$ is greater than element $i+1$, swap them.
  • Selection: Pass $i$: Find the $i-th$ smallest element and swap it with element $i$.
  • Insertion: Pass $i$: Make sure that the first $i+1$ elements are sorted.

Questions 1-4: Here is our initial vector:

Index:  0  1  2  3  4  5  6  7  8  9
Value: 46 28  5 56 47 85 44 14 66 72

After one pass of bubble sort:

Question 1: What value is at index 0?

Answer 28

Question 2: What value is at index 4?

Answer 56

Question 3: What value is at index 5?

Answer 44

Question 4: What value is at index 9?

Answer 85

Questions 5-8: Here is our initial vector:

Index:  0  1  2  3  4  5  6  7  8  9
Value: 50 64 14 31 13 84 31 48 21 54

After two passes of selection sort:

Question 5: What value is at index 0?

Answer 12

Question 6: What value is at index 1?

Answer 14

Question 7: What value is at index 2?

Answer 64

Question 8: What value is at index 3?

Answer 31

Questions 9-12: Here is our initial vector:

Index:  0  1  2  3  4  5  6  7  8  9
Value: 92 99 24 73 14 76 93 57 28 88

After two passes of insertion sort:

Question 9: What value is at index 0?

Answer 24

Question 10: What value is at index 1?

Answer 92

Question 11: What value is at index 2?

Answer 99

Question 12: What value is at index 3?

Answer 73

PDF Download, 2022 Class Stats, 2023 Class Stats