Glossary
Binary Search
An efficient search algorithm that repeatedly divides a *sorted* list in half, eliminating half of the remaining elements in each step, until the target is found.
Example:
When playing '20 Questions' to guess a number between 1 and 100, you're essentially using a binary search by asking 'Is it higher or lower than 50?' to quickly narrow down the possibilities.
Efficiency
A measure of how well an algorithm uses computational resources (like time or memory) to complete its task. More efficient algorithms use fewer resources.
Example:
A program that finds a specific item in a large database in milliseconds is demonstrating high efficiency compared to one that takes several minutes.
Linear (Sequential) Search
An algorithm that checks each item in a list, one by one, in order, until the target is found or the end of the list is reached.
Example:
If you're looking for a specific song on a playlist that isn't shuffled, you might use a linear search by listening to each song from the beginning until you find it.
Searching Algorithms
Computational procedures designed to find a specific item or value within a collection of data.
Example:
When you type a query into a search engine, it uses complex searching algorithms to quickly find relevant web pages from billions of options.
Sorted List
A list where elements are arranged in a specific order (e.g., numerically from smallest to largest, or alphabetically).
Example:
A phone book is a great example of a sorted list because names are arranged alphabetically, making it easy to find a specific contact.
Unsorted List
A list where elements are not arranged in any particular order.
Example:
Your backpack after a long school day, with books, pens, and snacks thrown in randomly, represents an unsorted list of items.
Worst-case scenario
The input or condition that causes an algorithm to perform the maximum number of operations or take the longest possible time to complete.
Example:
For a linear search, the worst-case scenario is when the item you're looking for is the very last item in the list, or not in the list at all.
