algorithm
An algorithm is a finite sequence of well-defined steps that takes zero or more inputs and produces an output, solving a problem or computing a result. Each step must be unambiguous, and the process must finish after a finite number of steps:
Algorithms are independent of any programming language. The same procedure can be written in Python or C, or expressed as plain prose, a flowchart, or pseudocode before it becomes runnable code.
Correctness and efficiency are judged separately. An algorithm is correct when it returns the right output for every valid input, and its efficiency is described by time complexity and space complexity, usually in Big O notation.
Common families include sorting algorithms that arrange data into order and search algorithms such as binary search that locate a value. Graph algorithms form another family, traversing networks of connected nodes.
An algorithm usually operates over a data structure that organizes the data it works on, and the choice of structure often shapes which algorithms are practical.
Related Resources
Tutorial
Sorting Algorithms in Python
In this tutorial, you'll learn all about five different sorting algorithms in Python from both a theoretical and a practical standpoint. You'll also learn several related and important concepts, including Big O notation and recursion.
For additional information on related topics, take a look at the following resources:
- How to Do a Binary Search in Python (Tutorial)
- Build a Maze Solver in Python Using Graphs (Tutorial)
- Introduction to Sorting Algorithms in Python (Course)
- Common Python Data Structures (Guide) (Tutorial)
- Recursion in Python: An Introduction (Tutorial)
- Thinking Recursively in Python (Tutorial)
- Creating a Binary Search in Python (Course)
- Mazes in Python: Build, Visualize, Store, and Solve (Course)
- Stacks and Queues: Selecting the Ideal Data Structure (Course)
- Records and Sets: Selecting the Ideal Data Structure (Course)
- Dictionaries and Arrays: Selecting the Ideal Data Structure (Course)
- Recursion in Python (Course)
- Recursion in Python: An Introduction (Quiz)
- Thinking Recursively With Python (Course)