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

What must be true before binary search is used?
  1. The list must be sorted
  2. The list must contain only even numbers
  3. The list must have no duplicates
  4. The list must be stored in hexadecimal

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 idea of bubble sort?
  1. Compare adjacent values and swap if out of order
  2. Split the list into halves and merge
  3. Always place the smallest item directly into position 0
  4. Use a binary tree to reorder values

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 steps to solve a problem
  2. A programming language used only for AI
  3. A file format for storing code
  4. Any list of ideas whether executable or not

Question 6

Why is pseudocode used when designing algorithms?
  1. It is language-independent and focuses on logic
  2. It runs faster than compiled code
  3. It automatically creates a user interface
  4. It can only be understood by Python programmers

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 the purpose of a trace table?
  1. To track how variable values change step-by-step during an algorithm
  2. To compress source code automatically
  3. To convert pseudocode into machine code
  4. To draw network topology diagrams

Question 11

What is an algorithm?
  1. A step-by-step set of instructions
  2. A programming language
  3. A hardware component
  4. A storage location

Question 12

What is sequencing?
  1. Putting instructions in order
  2. Repeating instructions
  3. Making a decision in an algorithm
  4. Removing unnecessary detail

Question 13

What is selection?
  1. Making a decision in an algorithm
  2. Repeating steps
  3. Putting steps in order
  4. Splitting into sub-tasks

Question 14

What is iteration?
  1. Repeating a series of instructions
  2. Choosing a path based on a condition
  3. Putting instructions into a fixed order
  4. Removing unnecessary detail from a problem

Question 15

What is a variable?
  1. A named value that can change
  2. Fixed value
  3. Flowchart symbol
  4. Output command

Question 16

What is a subroutine?
  1. A reusable section of an algorithm
  2. A single variable
  3. A flowchart decision
  4. An input value

Question 17

In a flowchart, what does a diamond mean?
  1. Decision
  2. Process
  3. Input/output
  4. Start/end

Question 18

In a flowchart, what does a rectangle mean?
  1. Process
  2. Decision
  3. Input/output
  4. Start/end

Question 19

In a flowchart, what does a parallelogram mean?
  1. Input/output
  2. Decision
  3. Process
  4. Start/end

Question 20

In a flowchart, what does an oval mean?
  1. Start/end
  2. Decision
  3. Input/output
  4. Process

Question 21

What is pseudocode?
  1. Algorithm steps written in plain language
  2. Instructions written directly in binary
  3. A flowchart made only of symbols
  4. A file format used to store source code

Question 22

Which loop repeats a set number of times?
  1. For loop
  2. While loop
  3. If statement
  4. Subroutine call

Question 23

Which loop runs while a condition remains true?
  1. While loop
  2. For loop
  3. If statement
  4. Return statement

Question 24

Which keyword starts a decision in code?
  1. if
  2. for
  3. while
  4. print

Question 25

Which are Boolean values?
  1. True and False
  2. Yes and No
  3. On and Off
  4. Up and Down

Question 26

What is decomposition?
  1. Breaking a problem into smaller parts
  2. Removing unnecessary detail from a problem
  3. Making a decision in an algorithm
  4. Repeating instructions while a condition is true

Question 27

What is abstraction?
  1. Removing unnecessary detail
  2. Breaking into parts
  3. Repeating steps
  4. Listing all cases

Question 28

What is a trace table for?
  1. Tracking values at each step
  2. Drawing flowcharts
  3. Saving code
  4. Encrypting files

Question 29

How does linear search work?
  1. Checks each item in order
  2. Starts in the middle
  3. Sorts first
  4. Checks first and last only

Question 30

Why are subroutines used in programs?
  1. To reuse sections of code
  2. To avoid requiring testing
  3. To make code run faster
  4. To prevent all logic errors

Question 31

What can binary search only be used on?
  1. Sorted list
  2. Random list only
  3. List of text only
  4. List with duplicates removed

Question 32

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

Question 33

What does bubble sort compare?
  1. Adjacent items
  2. Random pairs only
  3. Only first and last items
  4. Only prime positions

Question 34

How does merge sort work?
  1. By splitting a list and then merging sorted halves
  2. By swapping random values only
  3. By checking only adjacent pairs
  4. By using no comparisons

Question 35

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

Question 36

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

Question 37

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

Question 38

What does decomposition in algorithm design mean?
  1. Breaking a problem into smaller sub-problems
  2. Combining all data into one field
  3. Removing all conditions
  4. Avoiding all loops

Question 39

What does abstraction in algorithm design mean?
  1. Ignoring unnecessary detail
  2. Adding every detail
  3. Using only low-level code
  4. Avoiding all variables

Question 40

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 41

What does a condition return?
  1. True or False
  2. A number only
  3. A text string only
  4. A loop count

Question 42

What is debugging?
  1. Finding and fixing errors
  2. Running code once
  3. Drawing a flowchart
  4. Saving as PDF

Question 43

What is the worst-case time complexity of linear search?
  1. \(O(n)\)
  2. \(O(1)\)
  3. \(O(log n)\)
  4. \(O(n log n)\)

Question 44

What is the worst-case time complexity of binary search?
  1. \(O(log n)\)
  2. \(O(1)\)
  3. \(O(n)\)
  4. \(O(n^2)\)

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