Sorting and Searching Quiz

Sorting and Searching: ten questions on algorithms, search conditions, and operation counts. Includes calculations; answers explained.

Free, with no sign-up.

For High school students and adults reviewing the topic.

About 11 minutes. 10 questions.

How does it work?

  1. Choose one answer or enter a number as requested, then check it.
  2. Read the explanation before continuing.
  3. Round only the final answer to the precision requested.

What will you get?

See your score and review the reasoning behind each answer.

Question 1A binary search halves an array of 63 items after each unsuccessful midpoint check. What is the maximum number of midpoint comparisons? Enter a whole number.

Answers within 0.5 of the expected value are accepted.

Question 2One left-to-right bubble-sort pass starts with 5, 2, 4, 1. Each adjacent pair is swapped if its left value is larger, and the next pair uses the updated list. How many swaps occur? Enter a whole number.

Answers within 0.5 of the expected value are accepted.

Question 3A linear search checks a list of 27 records from the start for a missing key. How many records does it inspect in the worst case? Enter a whole number.

Answers within 0.5 of the expected value are accepted.

Question 4Within a database, users need fast lookups by surname and by account number while keeping one main record store. What supports both?
Question 5A binary search finds one matching key, but a report needs the earliest match among several duplicates. What must the implementation establish?
Question 6Textbook analysis says comparison sorting needs roughly n log n comparisons in the general worst case. Which scope is essential?
Question 7Before choosing an algorithm, a programmer wants binary search to locate a record in an array. What condition supports discarding half the candidates?
Question 8Records are sorted by a comparison that places a value before itself. Why is that a problem?
Question 9A one-time lookup is needed in a short unsorted list. Which comparison is useful when selecting a method?
Question 10Records are first ordered by arrival time, then sorted by score. Equal-score records must keep their earlier order. Which property is needed?

Answer every question to see and share your score.

Read the topic guide