Skip to content
fiveyearsdev

Tag

#algorithms

24 articles tagged algorithms.

DSAbeginner

Arrays and Dynamic Arrays: Random Access and Amortized O(1) Append

A diagram-first guide to the array and dynamic array data structure: O(1) random access, why append is amortized O(1) via doubling, time complexity, and interview questions.

14 min read
DSAintermediate

Balanced Search Trees: How AVL and Red-Black Trees Stay Fast

Balanced search trees explained: AVL and red-black, the self-balancing binary search tree data structure that guarantees O(log n). Rotations, time complexity, and interview questions.

17 min read
DSAbeginner

Big-O and Time Complexity: Reading an Algorithm’s Cost Straight Off the Code

A diagram-first guide to Big-O notation and time complexity analysis: the growth classes from O(1) to O(n!), reading complexity off code, space complexity, amortized analysis, and interview prep.

20 min read
DSAintermediate

Binary Search: Halving a Sorted World Down to One Answer

A diagram-first guide to the binary search algorithm: the lo/hi/mid loop, avoiding overflow, lower and upper bound, binary search on the answer, O(log n) time complexity, and interview prep.

16 min read
DSAintermediate

Binary Search Trees: One Rule for Fast Search, Insert, and Delete

A diagram-first guide to the binary search tree data structure and its algorithms: search, insert, in-order sort, and the three delete cases, with time complexity and interview questions.

14 min read
DSAbeginner

Binary Trees Explained: Traversals, Height, and Why In-Order Is Sorted

A diagram-first guide to the binary tree data structure: nodes, terminology, the three DFS traversals plus level-order BFS, height and time complexity, and a complete interview-ready implementation.

15 min read
DSAintermediate

Breadth-First Search: Finding the Shortest Path One Ripple at a Time

The breadth-first search (BFS) algorithm: explore a graph level by level with a queue, find the shortest path in an unweighted graph, grid and multi-source BFS, time complexity, and interview prep.

18 min read
DSAintermediate

Depth-First Search: Go Deep, Backtrack, and the Three-Colour Cycle Trick

The depth-first search (DFS) algorithm explained: recursion vs an explicit stack, three-colour cycle detection, connected components, flood fill, O(V+E) time complexity, and interview questions.

19 min read
DSAintermediate

Dynamic Programming: Turning Exponential Recursion Into Linear Time by Remembering

The dynamic programming algorithm explained: memoization vs tabulation, optimal substructure, overlapping subproblems, the 0/1 knapsack, time complexity, and interview prep.

17 min read
DSAbeginner

The Graph: How Software Models Maps, Friends, and the Web

A diagram-first guide to the graph data structure: vertices and edges, adjacency list vs matrix, degree, connected components, time complexity, and a complete implementation for interviews.

13 min read
DSAintermediate

Greedy Algorithms: When Grabbing the Best Right Now Actually Works

A diagram-first guide to greedy algorithms: interval scheduling, the exchange argument that proves a greedy choice is safe, where greedy fails, time complexity, and interview prep.

17 min read
DSAintermediate

Hash Tables Explained: How Maps and Sets Get O(1) Lookups

A diagram-first guide to the hash table data structure: hashing, buckets, collisions, chaining, load factor, resize, equals/hashCode contract, time complexity, and hash map interview questions.

18 min read
DSAintermediate

Heaps & Priority Queues Explained: The Binary Heap Behind Always-Next-Urgent

A friendly, diagram-first guide to the binary heap and priority queue data structure: the array embedding, sift-up and sift-down, heapify, time complexity, and interview follow-ups.

15 min read
DSAintermediate

Linked Lists Explained: Nodes, Pointers, In-Place Reversal, and Floyd's Cycle Detection

A diagram-first guide to the linked list data structure: singly vs doubly linked nodes, O(1) splicing, in-place reversal, Floyd cycle detection, plus time complexity and interview prep.

14 min read
DSAintermediate

Queues and Deques: FIFO, the Circular Buffer, and the Sliding-Window Trick

A diagram-first guide to the queue and deque data structure: FIFO enqueue and dequeue, the circular buffer (ring) fix, sliding window maximum, time complexity, and interview questions.

14 min read
DSAintermediate

Recursion and Backtracking: Trusting a Smaller Version of the Problem

Recursion and backtracking explained with diagrams: base case, call stack, choose-explore-unchoose, pruning, time complexity, and interview code for subsets, permutations, and N-queens.

17 min read
DSAintermediate

Sliding Window: Turning O(n²) Subarray Scans Into One Clean Pass

The sliding window algorithm explained: fixed and variable windows, the two-pointer technique, amortized O(n) time complexity, and interview code for max subarray sum and longest substring.

13 min read
DSAintermediate

Sorting Algorithms: Merge Sort, Quicksort, and Why a Bad Pivot Costs You O(n²)

A diagram-first guide to sorting algorithms: insertion sort, merge sort, quicksort partition and pivot, heap sort, stability, the O(n log n) lower bound, time complexity, and interview prep.

18 min read
DSAbeginner

The Stack: Undo, Recursion, and the O(n) Trick Interviewers Love

The stack data structure (LIFO) explained: push, pop, peek in O(1), the call stack behind recursion, and the monotonic stack, with time complexity and a full implementation for your coding interview.

13 min read
DSAintermediate

Topological Sort: Ordering a DAG So Every Prerequisite Comes First

The topological sort algorithm on a DAG: Kahn's algorithm with in-degrees and DFS post-order, how it detects a cycle, O(V+E) time complexity, and interview questions.

16 min read
DSAintermediate

Two Pointers: Turning an O(n²) Pair Hunt Into a Single O(n) Walk

The two pointers algorithm explained: converging and fast/slow pointers, two-sum on a sorted array, valid palindrome, container with most water, O(n) time complexity, and interview prep.

16 min read
DSAintermediate

Union-Find (Disjoint Set Union): Merging Groups in Almost No Time

A diagram-first guide to the union-find (disjoint set union) data structure: find and union, path compression, union by rank, near-constant time complexity, and interview code.

12 min read
DSAbeginner

The Trie: How Autocomplete Finishes Your Sentences

A friendly, diagram-first tour of the trie (prefix tree), the data structure behind autocomplete: insert, search, and prefix lookups step by step, plus a complete implementation.

10 min read
DSAadvanced

Dijkstra's Algorithm: How Your Map Finds the Fastest Route

A friendly, diagram-first walk through Dijkstra's shortest path algorithm: the ripple intuition, the invariant behind it, a step-by-step trace on a real graph, and a complete implementation.

6 min read