Sorting and searching algorithms Quiz
Studying this course? Keep your progress in one place.
Pick an answer for each. Quizzes never use energy.
5 questions, one answer each
Each answer is checked as you go, with why.
See all 5 questions
1. Bubble sort on 5, 2, 4, 1. What is the list after the first pass?
- A. 2, 4, 1, 5
- B. 2, 5, 4, 1
- C. 1, 2, 4, 5
- D. 2, 4, 5, 1
2. Quick sort on 9, 4, 7, 2, 8, 5, 6 with the middle item as pivot. Which item is the first pivot?
- A. 7
- B. 2
- C. 8
- D. 6
3. A binary search for 23 in the ordered list 2, 5, 9, 12, 17, 23, 30, 41. How many items are compared with 23?
- A. 2
- B. 4
- C. 3
- D. 5
4. How many comparisons are made in the first pass of a bubble sort of 9 items?
- A. 8
- B. 9
- C. 10
- D. 7
5. What must be true of a list before a binary search?
- A. Items are all different
- B. It has an even number of items
- C. Items are integers
- D. It is in order