AP CSP Unit 6: Algorithms, Efficiency, and Simulations

27 multiple-choice questions on AP Computer Science Principles Unit 6, Algorithms, Efficiency, and Simulations, organized by topic. They are not tied to any one class or teacher: they follow the College Board course framework. Learn the 7 key terms with the flashcards first, then test yourself. Every answer comes with a short explanation.

Take the practice test · Flashcards · All study tools

What it covers

  1. 6.1 Developing algorithms
  2. 6.2 Searching and efficiency
  3. 6.3 Simulations

Key terms

6.3 Simulations

Algorithm
A finite set of instructions that accomplishes a task
Linear search
Checking each element in order
Binary search
Repeatedly checking the middle of a sorted list and discarding half
Reasonable time
Algorithms whose steps grow polynomially with input size
Heuristic
An approach that finds an approximate solution when an exact one is impractical
Undecidable problem
A problem for which no algorithm always gives a correct yes-or-no answer
Simulation
A model of a real-world process using abstractions

Sample practice questions

  1. An algorithm is

    1. any computer program, as long as it is written in Java
    2. a type of computer hardware that carries out instructions
    3. a random sequence of steps that may or may not finish
    4. a finite set of instructions that accomplishes a specific task

    Answer: D. a finite set of instructions that accomplishes a specific task Algorithms can be expressed in natural language, diagrams, pseudocode or code.

  2. Linear search on a list of 1,000 unsorted names checks, in the worst case,

    1. 10 names
    2. 500 names
    3. 1 name
    4. 1,000 names

    Answer: D. 1,000 names Without order, each element may need to be checked.

  3. A simulation is

    1. an exact copy of reality that includes every detail
    2. always less useful than a real-world experiment
    3. a program that models a real-world process using abstractions
    4. a type of compression used for large data sets

    Answer: C. a program that models a real-world process using abstractions Simulations represent real events, removing details that are less important.

  4. Every algorithm can be constructed using

    1. only loops, with no IF statements
    2. only IF statements, with no loops
    3. recursion only, with no sequencing
    4. sequencing, selection and iteration

    Answer: D. sequencing, selection and iteration These three building blocks are enough to express any algorithm.

  5. Binary search can be used only when

    1. the list has fewer than 100 elements
    2. the list contains numbers only
    3. the list is sorted
    4. the list is unsorted

    Answer: C. the list is sorted Binary search compares with the middle element to discard half, which requires order.

  6. An advantage of a simulation over a real-world experiment is that it

    1. always gives exact results that match the real world in every detail
    2. never contains bias, since the computer makes all of the decisions
    3. doesn't need any assumptions, since it uses real data from the world
    4. can be faster, cheaper and safer, and test conditions that are hard to create

    Answer: D. can be faster, cheaper and safer, and test conditions that are hard to create For example, simulating a hurricane is safer than waiting for one.

  7. Selection in an algorithm refers to

    1. running each step in order, one after another
    2. repeating steps until a condition is met
    3. choosing which steps to run based on a condition
    4. picking an item from a list at random

    Answer: C. choosing which steps to run based on a condition IF statements implement selection.

  8. About how many steps does binary search need in the worst case for a sorted list of 1,000,000 items?

    1. 1,000,000
    2. 20
    3. 500,000
    4. 1,000

    Answer: B. 20 Each step halves the list; 2²⁰ ≈ 1,000,000.

  9. A limitation of simulations is that

    1. they can't use random numbers, so they can't model chance events
    2. they rely on simplifying assumptions, so results may not match reality
    3. they can't be repeated, since each run changes the program's code
    4. they are always more expensive to run than real-world experiments

    Answer: B. they rely on simplifying assumptions, so results may not match reality Simplifications and possible bias in the model affect results.

  10. Two different algorithms that solve the same problem

    1. must produce different results for at least some inputs
    2. must be written in different programming languages
    3. can both be correct while differing in efficiency or clarity
    4. can't both be correct, since only one can be most efficient

    Answer: C. can both be correct while differing in efficiency or clarity Many algorithms can solve a problem; some are faster or easier to understand.

Practice all 27 questions

More AP Computer Science Principles

Studying for a test in your own class? Make a practice test from your class notes.