Foundations · StudentHub Lesson
Algorithms & Pseudocode
Learn what algorithms are and how to describe them using pseudocode before writing real code.
What you will learn
- Define what an algorithm is
- Write simple algorithms in plain pseudocode
- Compare different algorithms for the same problem
- Understand efficiency at a basic level
- Practice tracing through an algorithm step by step
Watch the lesson
Intro to Algorithms: Crash Course Computer Science #13 · CrashCourse
Watch on YouTubeTopic notes
Main Idea
An algorithm is a precise sequence of steps used to solve a problem or complete a computation.
Key Concepts
- Algorithms exist independently of any programming language
- Pseudocode describes algorithm steps in plain, structured language
- Multiple algorithms can solve the same problem with different efficiency
- Tracing an algorithm means following its steps manually
Definitions
- Algorithm: a finite sequence of steps to solve a problem
- Pseudocode: informal, human-readable description of an algorithm
- Efficiency: how much time or resources an algorithm needs
Syntax Example
```
START
SET total = 0
FOR each number in list
ADD number to total
PRINT total
END
```
Examples
- A recipe is an everyday algorithm
- Sorting a list of names alphabetically can be done with different algorithms
Common Mistakes
- Confusing pseudocode with actual programming syntax
- Skipping steps assuming they're 'obvious'
Key concepts
Important terms
- Algorithm
- A precise sequence of steps to solve a problem
- Pseudocode
- Plain-language representation of an algorithm's logic
Worked examples
Problem
Write pseudocode to find the largest number in a list
- 1. SET max = first number
- 2. FOR each number in list
- 3. IF number > max THEN max = number
- 4. PRINT max
Answer: The pseudocode correctly finds the maximum value
Quick revision
- Algorithms are step-by-step solutions
- Pseudocode is not real code
- Different algorithms can solve the same problem
- Efficiency measures speed/resources used
- Tracing helps verify correctness
Check your understanding
Question 1 · Multiple choice
What is an algorithm?
Question 2 · Multiple choice
What is pseudocode used for?
Question 3 · True or false
There is only ever one correct algorithm for a given problem.
Question 4 · Short answer
Give a real-world example of an algorithm.
Question 5 · Short answer
Why do we trace through an algorithm's steps?
Done with Algorithms & Pseudocode?
Sign in to save your progress across the library.