Skip to content

Algorithm

Easy — everyone uses thisGeneral Dev

ELI5 — The Vibe Check

An algorithm is just a step-by-step recipe for solving a problem. Sort a list? There is an algorithm. Find the shortest path? Algorithm. Make a sandwich? That is also an algorithm. In code, algorithms turn input into output through a defined sequence of steps. The trick is making them fast and correct.

Real Talk

An algorithm is a finite, deterministic sequence of instructions that transforms input into output, solving a well-defined problem. Algorithms are analyzed for time complexity (how long they take) and space complexity (how much memory they use), expressed in Big O notation. Classic algorithms include sorting (QuickSort, MergeSort), searching (binary search), and graph traversal (BFS, DFS).

Show Me The Code

// Binary search algorithm — finds a number in a sorted array:
function binarySearch(arr, target) {
  let left = 0, right = arr.length - 1;
  while (left <= right) {
    const mid = Math.floor((left + right) / 2);
    if (arr[mid] === target) return mid;
    if (arr[mid] < target) left = mid + 1;
    else right = mid - 1;
  }
  return -1; // not found
}
// O(log n) — much faster than checking every element

When You'll Hear This

"Which algorithm are you using to sort that?" / "The algorithm runs in O(n²) — too slow for large datasets."

Made with passive-aggressive love by manoga.digital. Powered by Claude.