Algorithms
Computer Science
Algorithm Overview
Common Algorithms
Programming Basics

Is there an overview of the most common algorithms?

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

Introduction

Yes, but the most useful overview is not just a flat list of famous names. A practical overview groups algorithms by the kind of problem they solve: searching, sorting, graph traversal, shortest paths, dynamic programming, greedy optimization, and string processing.

Searching and Sorting

Searching algorithms help you find an item, while sorting algorithms reorder data so later operations become easier.

Common searching ideas include:

  • linear search for unsorted data
  • binary search for sorted data
  • hash lookup for exact-key queries
python
1def binary_search(arr, target):
2    lo, hi = 0, len(arr) - 1
3    while lo <= hi:
4        mid = (lo + hi) // 2
5        if arr[mid] == target:
6            return mid
7        if arr[mid] < target:
8            lo = mid + 1
9        else:
10            hi = mid - 1
11    return -1
12
13print(binary_search([2, 4, 6, 8, 10], 8))

For sorting, the names worth recognizing are usually quicksort, mergesort, and heapsort, even though production code typically uses the language's built-in sort rather than a handwritten implementation.

Graph Algorithms

Graphs model relationships, dependencies, routes, and reachability. That makes graph algorithms valuable in far more domains than classroom pathfinding.

Common examples include:

  • breadth-first search for traversal and shortest paths in unweighted graphs
  • depth-first search for traversal, cycle detection, and components
  • Dijkstra's algorithm for shortest paths with nonnegative weights
  • topological sort for dependency ordering in directed acyclic graphs
python
1from collections import deque
2
3
4def bfs(graph, start):
5    seen = {start}
6    queue = deque([start])
7    order = []
8
9    while queue:
10        node = queue.popleft()
11        order.append(node)
12        for nxt in graph.get(node, []):
13            if nxt not in seen:
14                seen.add(nxt)
15                queue.append(nxt)
16
17    return order

These ideas appear in build systems, package managers, route planning, and workflow engines.

Dynamic Programming

Dynamic programming is useful when a problem contains overlapping subproblems and an optimal solution can be built from smaller optimal solutions.

Classic examples include:

  • Fibonacci-like recurrence problems
  • edit distance
  • longest common subsequence
  • knapsack
python
1def fib_dp(n):
2    if n < 2:
3        return n
4
5    dp = [0, 1]
6    for i in range(2, n + 1):
7        dp.append(dp[i - 1] + dp[i - 2])
8    return dp[n]

The important lesson is not the Fibonacci example itself. It is the habit of spotting repeated work and replacing it with memoization or tabulation.

Greedy Algorithms and Backtracking

Greedy algorithms make the best-looking local choice at each step. They work when local choices lead to a globally correct result.

Typical examples include:

  • interval scheduling
  • Huffman coding
  • some minimum-spanning-tree strategies

Backtracking is different. It explores candidate choices recursively and abandons branches that cannot lead to a valid solution.

Typical examples include:

  • Sudoku solving
  • N-Queens
  • constrained permutation search

These two families are often contrasted because one relies on local optimality while the other relies on structured search.

String and Text Algorithms

Strings deserve their own category because text processing is everywhere.

Common concepts include:

  • substring search
  • prefix and suffix reasoning
  • tries for prefix lookup
  • rolling hashes
  • specialized matchers such as Knuth-Morris-Pratt

Even if you never implement advanced text algorithms by hand, it helps to know what kind of problem each one is meant to accelerate.

How to Choose the Right Algorithm

The right algorithm depends on more than Big-O notation. Real decisions also depend on:

  • input size
  • memory limits
  • whether data is static or changing
  • latency versus throughput goals
  • implementation complexity

An O(n) scan may be perfect for one problem while a more advanced structure is justified for another. Understanding the shape of the problem matters more than collecting algorithm names.

Common Pitfalls

The most common mistake is memorizing algorithm names without learning what kinds of problems they solve.

Another common issue is ignoring the underlying data structure. A strategy that is great on a sorted array is not automatically great on a linked list or a graph. Developers also often reimplement standard algorithms in production when a library routine would be safer and easier to maintain.

Summary

  • The most common algorithms are best understood by problem family, not by isolated names.
  • Searching, sorting, graph traversal, dynamic programming, greedy methods, and backtracking cover a large share of practical work.
  • Standard-library implementations are usually the right production choice for common operations.
  • Big-O matters, but real input shape and system constraints matter too.
  • Knowing when to apply an algorithm is more valuable than memorizing a definition.

Related reading
Course
Intermediate
27 lessons
15 hours
DSA Fundamentals

Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Data Structures & Algorithms practice on Codemia

Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.

Practice algorithms

All Rights Reserved.