Computer Science Study Notes
Computer Science – Introduction to Algorithms
An algorithm is a step-by-step procedure to solve a problem.
Characteristics of a good algorithm: 1. Clear and unambiguous steps. 2. Input: data required to solve
the problem. 3. Output: the result after execution. 4. Finiteness: must terminate after a finite number of
steps. 5. Efficiency: uses minimal time and resources.
Example: Algorithm to find the largest number in a list. 1. Set the first number as the largest. 2.
Compare with the next number. 3. If larger, update the largest number. 4. Repeat until all numbers are
checked. 5. Output the largest number.
Common types of algorithms: • Searching (linear search, binary search) • Sorting (bubble sort,
quicksort) • Pathfinding (Dijkstra’s algorithm)