What is an algorithm?
An algorithm is a sequence of well-defined, precise steps for solving a problem. An algorithm needs to terminate and produce an answer. In computer science language, we say that it must terminate in a finite number of steps.
In math classes, algorithms help students learn to multiply and divide, to find the greatest common divisor (GCD), and to solve a system of linear equations.
Computer programs execute algorithms. In a program, the steps of an algorithm are implemented in a programming language. Algorithms and their implementations as a program need to not only terminate but produce the correct result. As all software written is based on algorithms, algorithms impact our society and economies in profound and lasting ways.
Algorithms in your life
In daily life, we use algorithms to describe solutions to problems and we use them to accomplish tasks (also called computational thinking).
Examples from everyday life:
- Making a peanut butter and jelly sandwich
- More generally, cooking by following a recipe
- Going to the grocery store with a list and walking down every aisle at most once
- Making a snowman
- Playing solitaire
- Wrapping a gift the way it is done at Bloomingdale’s
- Finding a parking spot in a large parking lot (e.g., mall, airport parking)
- Arranging your Netflix movie queue according to your preferences using only the “move to the top” feature
- Every student should be able to come up with an example in their life
In classes students take, algorithms are used to learn skills and to execute procedures in a correct and efficient way. Examples include
- multiplying and dividing two numbers
- determining the average and median of a given set of numbers
- taking the square root of a number
- finding the greatest common divisor (GCD, Euclid’s Algorithm)
- solving a system of linear equations (Gaussian Elimination)
- evaluating a polynomial (e.g., evaluate 2x4-x3+4x2+12 for x=3)
- determining your schedule of classes for next year based on course offerings, prerequisites, preferences, and graduation requirements.
Algorithms are important in Computer Science
- Every program has an underlying algorithm that it implements
- For every problem there typically exist a number of algorithms solving it. The algorithms may differ considerably in the problem-solving approach taken, the resources needed (including time and space), and other requirements.
- Designing algorithms is a creative intellectual activity.
- There exist a number of common algorithm design techniques that work for many problems. However, the process of finding an algorithm solving a specific problem cannot be automated.
- The execution of incorrect algorithms in a program can lead to wrong results, systems failure, loss of investments, and loss of life.
Algorithmic Thinking
Algorithmic thinking refers to our ability solving problems in an effective way leading to an algorithm. Algorithmic thinking also includes the ability to understand that some problems cannot be solved by an algorithm. It involves
- the ability to specify a problem precisely
- the ability to create and describe an algorithm to solve the problem
- the ability to answer “what if” questions about the algorithm
- the ability to argue the correctness of an algorithm
- the ability to find examples of inputs on which the algorithm fails to work as expected (if not a correct algorithm)
Algorithmic thinking is part of Computational Thinking (CT) which is one of the strands in the 2011 CSTA K-12 curriculum (http://csta.acm.org/Curriculum/sub/CurrFiles/CSTA_K-12_CSS.pdf):
“CT is an approach to solving problems in a way that can be implemented with a computer. Students become not merely tool users but tool builders. They use a set of concepts, such as abstraction, recursion, and iteration, to process and analyze data, and to create real and virtual artifacts. CT is a problem-solving methodology that can be automated and transferred and applied across subjects. The power of computational thinking is that it applies to every other type of reasoning.
Computational thinking is thus a problem-solving methodology that can interweave computer science with all disciplines, providing a distinctive means of analyzing and developing solutions to problems that can be solved computationally. With its focus on abstraction, automation, and analysis, computational thinking is a core element of the broader discipline of computer science and for that reason it is interwoven through these computer science standards at all levels of K–12 learning.”
While computational thinking encompasses tasks done every day and includes problem solving approaches we use in general, algorithmic thinking is more focused on solving a well-defined problem in a way that can lead to coding a specified solution.