Sign in

Intro to Computer Science / Unit 3: Algorithms and Problem Solving

3.1 What Is an Algorithm?

3 practice questionsNot yet reviewed

Notes

An algorithm is a finite, step-by-step set of instructions that solves a problem or completes a task.

  • A good algorithm is clear (each step is exact), finite (it ends), and correct (it gives the right result).
  • Order matters: swapping steps can change the result.
  • Algorithms use three building blocks: sequence (steps in order), selection (choosing with a condition) and iteration (repeating).
  • Example: a recipe is an algorithm. "Boil water, add pasta, wait 10 minutes, drain" is a sequence.

Practice

Which is the best definition of an algorithm?
Which building block describes repeating a step until a condition is met?
An algorithm for making a sandwich lists the steps: put on the top slice of bread, spread peanut butter, put on the bottom slice. What is wrong?

Ready for more? Take the Unit 3 test.