Algorithms and Programs
The scripts you created in the Maze demo contain all the essential control structures that programmers use to design algorithms:
- Sequence: An algorithm is a sequence of precise statements (blocks).
- Selection (if/else): An algorithm can select between two alternative paths based on some condition.
- Repetition (repeat): An algorithm can repeat a sequence of statements.
Algorithms are Everywhere
Here's an interesting fact: Computer scientists have proven that sequence, selection, and repetition are sufficient to build any algorithm that can be thought of. In other words, any algorithm can be expressed using only sequence, selection, and repetition.
Computer scientists write algorithms to solve problems. And we know now that sequence, selection, and repetition are sufficient to express any algorithm we can think of.
- Are there algorithms we can't think of? Or, to put that another way, are there problems that can't be solved by an algorithm? What do you think? That's one of the interesting questions we will take up in this course. In a few weeks, you'll know the answer.