Algorithms questions

By Interwoven Maths

Algorithms question collection

Review Algorithms questions for Computer Science, with correct answers shown and coverage across sequence, selection and iteration; trace tables; searching and sorting.

Back to Algorithms practice Back to Computer Science

Question 1

Which property must a list have before binary search?
  1. Items arranged in sorted order
  2. Items arranged in random order
  3. Items stored as hexadecimal values
  4. Items restricted to unique values

Question 2

In linear search, what is the maximum number of checks needed to find a value in a list of n items (worst case)?
  1. \(n\)
  2. \(1\)
  3. \(\log_2(n)\)
  4. \(n/2\)

Question 3

What is the key step in bubble sort?
  1. Compare adjacent items and swap those out of order
  2. Split the list and merge sorted halves
  3. Select the smallest remaining item for the next position
  4. Insert each item into a growing sorted section

Question 4

What does insertion sort build over time?
  1. A growing sorted section of the list
  2. A randomised section to improve speed
  3. A stack of unsorted values
  4. Two identical copies of the original list

Question 5

What best describes an algorithm?
  1. A finite sequence of unambiguous problem-solving steps
  2. Source code written in a particular language
  3. Input data stored for a program
  4. An unordered list of possible ideas

Question 6

Why is pseudocode useful when designing algorithms?
  1. It shows logic without depending on one language
  2. It executes faster than compiled machine code
  3. It automatically creates the user interface
  4. It tests the finished program on hardware

Question 7

Which test data type checks values exactly on the edge of valid input range?
  1. Boundary
  2. Normal
  3. Erroneous
  4. Live

Question 8

Which test data type uses typical valid values?
  1. Normal
  2. Boundary
  3. Erroneous
  4. Exhaustive

Question 9

Which test data type deliberately uses invalid input?
  1. Erroneous
  2. Normal
  3. Boundary
  4. Expected

Question 10

What is a trace table used for?
  1. Tracking variable values as an algorithm runs
  2. Showing decisions and processes as symbols
  3. Listing test cases and expected results
  4. Describing logic without language syntax

Question 11

What does selection sort do on each pass?
  1. Selects the smallest remaining item for the next position
  2. Swaps every adjacent out-of-order pair
  3. Splits the list into equal halves
  4. Inserts the next item into a sorted section

Question 12

What is linear search most useful for?
  1. Small or unsorted lists
  2. Sorted large lists
  3. Encrypted lists
  4. Lists stored in ROM

Question 13

What is an advantage of merge sort over bubble sort for a large list?
  1. It is generally faster
  2. It needs less storage
  3. It is simpler to code
  4. It needs presorted data

Question 14

How does merge sort work?
  1. Splits the list, then merges sorted sublists
  2. Swaps adjacent out-of-order items
  3. Selects the smallest item for each position
  4. Inserts each item into a growing sorted section

Question 15

In pseudocode, what does indentation usually show?
  1. Block structure
  2. Execution speed
  3. Data type size
  4. CPU frequency

Question 16

In a flowchart, what does a diamond represent?
  1. A decision
  2. A process step
  3. Input/output
  4. A subroutine call

Question 17

In a flowchart, what does a terminator represent?
  1. Start or end
  2. A condition
  3. A loop counter
  4. A variable assignment

Question 18

What does decomposition mean in algorithm design?
  1. Breaking a problem into smaller subproblems
  2. Removing detail that does not affect the solution
  3. Finding similarities between several problems
  4. Combining data into one large structure

Question 19

What does abstraction mean in algorithm design?
  1. Removing detail that does not affect the solution
  2. Breaking a problem into smaller subproblems
  3. Finding similarities between several problems
  4. Adding implementation detail before design

Question 20

What is validation in algorithm design?
  1. Checking input follows required rules
  2. Converting pseudocode to machine code
  3. Sorting data into ascending order
  4. Encrypting stored passwords

Question 21

Why can linear search suit a frequently changing list?
  1. The list need not be sorted
  2. One item needs checking
  3. The search area halves
  4. A search tree is required

Question 22

What is an advantage of binary search on a large sorted list?
  1. It usually needs fewer comparisons
  2. It can search unsorted data directly
  3. It checks every item in order
  4. It sorts the list while searching

Question 23

What is an advantage of bubble sort over merge sort for a short list?
  1. It is simpler to implement
  2. It generally uses fewer comparisons
  3. It splits the list recursively
  4. It needs one comparison per list

Question 24

Which is a disadvantage of merge sort?
  1. It needs extra storage while merging
  2. It must compare every pair of items
  3. It requires presorted data
  4. It needs many adjacent swaps

Question 25

What does a binary search do after comparing with the middle item?
  1. Discards half of the remaining search area
  2. Searches both halves of the list
  3. Moves to the next item in order
  4. Compares every item in the list

Question 26

For n items, how many full passes can bubble sort need in the worst case?
  1. n − 1
  2. 1
  3. log₂ n

Question 27

What is a subroutine?
  1. A named block of code that performs a task
  2. A variable that stores one value
  3. A condition used for selection
  4. A loop that repeats instructions

Question 28

Why use decomposition when designing an algorithm?
  1. Make a complex problem more manageable
  2. Remove the need for testing
  3. Choose the programming language automatically
  4. Make every subproblem run in constant time

Question 29

What is a dry run?
  1. Manually tracing an algorithm with test data
  2. Running compiled code on hardware
  3. Checking the spelling of source code
  4. Writing a test plan

Question 30

Which statement about algorithms is correct?
  1. Two algorithms can solve one problem with different efficiency
  2. One problem determines one possible algorithm
  3. Algorithm efficiency depends only on programming language
  4. Changing input size leaves running time unchanged

About this topic

Review Algorithms questions for Computer Science, with correct answers shown and coverage across sequence, selection and iteration; trace tables; searching and sorting.

This topic covers

Example question types