DSA-VerseLearn by watching code run
DashboardData StructuresAlgorithmsVisualizerCORECoding PlaygroundInterview QuestionsComplexity AnalyzerLearning NotesBookmarksLearning ProgressSettings

Algorithms

Explanations, pseudocode, an embedded interactive visualization, implementations in JavaScript, Python, Java and Go, complexity and interview variations.

Searching

Linear Search

Interactive

Checks every element from left to right until the target is found or the array ends. Works on unsorted data.

O(n) · 4 languages

Binary Search

Interactive

Searches a sorted array by repeatedly comparing the target with the middle element and discarding the half that cannot contain it.

O(log n) · 4 languages

Lower Bound

Planned

First index whose value is ≥ target in a sorted array (binary-search variant).

O(log n)

Upper Bound

Planned

First index whose value is > target in a sorted array.

O(log n)

Search in Rotated Sorted Array

Planned

Binary search that first decides which half is still sorted.

O(log n)

Sorting

Bubble Sort

Interactive

Repeatedly compares adjacent elements and swaps them when they are out of order, so the largest unsorted value bubbles to the end after every pass.

O(n²) · 4 languages

Selection Sort

Interactive

Divides the array into a sorted prefix and an unsorted suffix. Each pass selects the minimum of the unsorted part and swaps it into the next position of the prefix.

O(n²) · 4 languages

Insertion Sort

Interactive

Builds a sorted prefix one element at a time: the next element (the key) is lifted out, larger elements of the prefix shift one step right, and the key drops into the gap.

O(n²) · 4 languages

Merge Sort

Planned

Divide the array in halves, sort each recursively, merge the sorted halves.

O(n log n)

Quick Sort

Planned

Partition around a pivot, then sort both sides recursively.

O(n log n) avg

Heap Sort

Planned

Build a max-heap, then repeatedly move the maximum to the end.

O(n log n)

Counting Sort

Planned

Count occurrences of each key in a small integer range.

O(n + k)

Radix Sort

Planned

Stable sort digit by digit, least significant first.

O(d·(n + b))

Array & Data-Structure Operations

Reverse an Array

Interactive

Reverses an array in place with two pointers: swap the outermost pair, move both pointers inward, and stop when they meet.

O(n) · 4 languages

Two Sum

Interactive

Finds two indexes whose values add up to a target in one pass, storing each value's index in a hash map and looking up the complement (target − value).

O(n) · 4 languages

Singly Linked List Insertion

Interactive

Inserts a new node at a given position: walk to the node just before the position, point the new node at its successor, then re-link the predecessor to the new node.

O(n) · 4 languages

Stack Push and Pop

Interactive

A stack is Last-In-First-Out (LIFO): push adds to the top, pop removes from the top. A fixed capacity shows overflow (push when full) and underflow (pop when empty).

O(1) · 4 languages

Queue Enqueue and Dequeue

Interactive

A queue is First-In-First-Out (FIFO): enqueue adds at the rear, dequeue removes from the front. This circular-array queue wraps the rear pointer around to reuse freed slots.

O(1) · 4 languages

Recursion and Backtracking

Basic Recursion

Planned

Base case + recursive case; how the call stack grows and unwinds.

varies

Factorial

Planned

n! = n × (n−1)!, the classic first recursive function.

O(n)

Fibonacci

Planned

Naive recursion recomputes subproblems — exponential time.

O(2ⁿ)

Tower of Hanoi

Planned

Move n−1 disks aside, move the largest, move n−1 back on top.

O(2ⁿ)

Subsets

Planned

Include / exclude each element to generate the power set.

O(n·2ⁿ)

Permutations

Planned

Choose, recurse, un-choose to list every ordering.

O(n·n!)

N-Queens

Planned

Place queens row by row, backtracking on conflicts.

O(n!)

Sudoku Solver

Planned

Fill empty cells with valid digits, undo on dead ends.

exponential

Tree Algorithms

Binary Tree Inorder Traversal

Interactive

Recursively visits the left subtree, then the node itself, then the right subtree (Left → Root → Right). On a Binary Search Tree this produces the values in sorted order.

O(n) · 4 languages

Preorder Traversal

Planned

Root → Left → Right; used to copy/serialise trees.

O(n)

Postorder Traversal

Planned

Left → Right → Root; used to delete/evaluate trees.

O(n)

Level Order Traversal

Planned

BFS on a tree with a queue, level by level.

O(n)

Tree Height

Planned

1 + max(height(left), height(right)).

O(n)

Lowest Common Ancestor

Planned

Deepest node that has both targets in its subtree.

O(n)

Graph Algorithms

Graph BFS (Breadth-First Search)

Interactive

Explores the graph level by level using a queue. Because vertices are discovered in order of distance, BFS also finds the shortest path (fewest edges) from the start in an unweighted graph.

O(V + E) · 4 languages

Graph DFS (Depth-First Search)

Interactive

Goes as deep as possible along each branch before backtracking. This recursive version uses the call stack as its implicit stack.

O(V + E) · 4 languages

Dijkstra's Algorithm

Planned

Shortest paths with non-negative weights using a min-priority queue.

O((V + E) log V)

Bellman-Ford

Planned

Relax every edge V−1 times; detects negative cycles.

O(V·E)

Floyd-Warshall

Planned

All-pairs shortest paths by dynamic programming over intermediate vertices.

O(V³)

Topological Sorting

Planned

Linear order of a DAG respecting every edge (Kahn's algorithm / DFS).

O(V + E)

Kruskal's Algorithm

Planned

Minimum spanning tree by adding cheapest edges with Union-Find.

O(E log E)

Prim's Algorithm

Planned

Grow a minimum spanning tree from one vertex with a priority queue.

O(E log V)

Greedy Algorithms

Activity Selection

Planned

Pick the activity that finishes first, repeat.

O(n log n)

Fractional Knapsack

Planned

Take items by best value/weight ratio, splitting the last one.

O(n log n)

Job Sequencing

Planned

Schedule highest-profit jobs into the latest free slot before their deadline.

O(n log n)

Huffman Coding

Planned

Merge the two least frequent symbols repeatedly to build an optimal prefix code.

O(n log n)

Dynamic Programming

Fibonacci DP

Planned

Memoise or tabulate to turn O(2ⁿ) into O(n).

O(n)

Climbing Stairs

Planned

ways(n) = ways(n−1) + ways(n−2).

O(n)

0/1 Knapsack

Planned

Best value with capacity W, each item taken at most once.

O(n·W)

Longest Common Subsequence

Planned

2-D table over prefixes of both strings.

O(m·n)

Longest Increasing Subsequence

Planned

O(n²) DP or O(n log n) with patience sorting.

O(n log n)

Coin Change

Planned

Fewest coins (or number of ways) to make an amount.

O(n·amount)

Matrix Chain Multiplication

Planned

Best parenthesisation via interval DP.

O(n³)

Grid Unique Paths

Planned

paths(r, c) = paths(r−1, c) + paths(r, c−1).

O(m·n)