Algorithm & Data Structure Visualizer

Interactive animations to help you understand how algorithms and data structures work under the hood.

No algorithms found matching your search.

Sorting Algorithms

Bubble Sort

Repeatedly swaps adjacent elements if they are in the wrong order.

O(n²)

Selection Sort

Finds the minimum element and places it at the beginning each pass.

O(n²)

Insertion Sort

Builds sorted array one element at a time by inserting into position.

O(n²)

Merge Sort

Divides array in half, sorts each half, then merges them back.

O(n log n)

Quick Sort

Picks a pivot and partitions the array around it recursively.

O(n log n)

Heap Sort

Builds a max heap and repeatedly extracts the maximum element.

O(n log n)

Counting Sort

Non-comparison sort that counts occurrences of each value. Linear time for bounded integers.

O(n + k)

Radix Sort

Sorts integers digit by digit from least significant to most significant.

O(nk)

Searching Algorithms

Linear Search

Sequentially checks each element until the target is found.

O(n)

Binary Search

Halves the search space each step on a sorted array.

O(log n)

Data Structures

Stack

Last-In-First-Out (LIFO) structure with push and pop operations.

LIFO

Queue

First-In-First-Out (FIFO) structure with enqueue and dequeue.

FIFO

Linked List

Linear collection of nodes connected by pointers.

Dynamic

Binary Search Tree

Tree where left child < parent < right child.

O(log n)

Min/Max Heap

Complete binary tree with heap property — bubble up & down.

O(log n)

Hash Table

Key-value store using hash functions with collision handling.

O(1) avg

Trie (Prefix Tree)

Tree structure for efficient prefix-based string search and autocomplete.

O(L)

Union-Find

Disjoint set structure with union by rank and path compression.

O(α(n))

Graph Algorithms

Breadth-First Search

Explores all neighbors at present depth before moving deeper.

O(V + E)

Depth-First Search

Explores as far as possible along each branch before backtracking.

O(V + E)

Dijkstra's Algorithm

Finds shortest paths from a source to all vertices.

O(V²)

Bellman-Ford

Finds shortest paths even with negative edge weights. Detects negative cycles.

O(VE)

Kruskal's MST

Builds minimum spanning tree by picking smallest edges.

O(E log E)

Prim's MST

Grows the minimum spanning tree one vertex at a time using a priority queue.

O(E log V)

Topological Sort

Linear ordering of vertices in a directed acyclic graph.

O(V + E)

Dynamic Programming

Fibonacci

Memoization vs tabulation approaches to compute Fibonacci numbers.

O(n)

0/1 Knapsack

Maximize value with weight constraint using a 2D DP table.

O(nW)

Longest Common Subsequence

Find the longest subsequence common to two sequences.

O(mn)

Coin Change

Find the minimum number of coins needed to make a given amount.

O(nS)

Edit Distance

Minimum insertions, deletions, and substitutions to transform one string into another.

O(mn)

Longest Increasing Subsequence

Find the length of the longest strictly increasing subsequence in an array.

O(n log n)

Trees

Tree Traversals

Inorder, Preorder, Postorder, and Level Order traversals animated.

O(n)

Pathfinding

A* Search

Heuristic-guided pathfinding on a grid — draw walls and watch.

Optimal

Maze Generation

Recursive backtracking to generate random mazes.

DFS-based

String Algorithms

KMP Pattern Matching

Efficient string search using a prefix failure function to avoid re-scanning.

O(n + m)

Problem-Solving Patterns

Two Pointers

Use two pointers converging from both ends to solve sorted array problems.

O(n)

Sliding Window

Maintain a window that slides across the array for optimal subarrays.

O(n)

Fast & Slow Pointers

Floyd's cycle detection — two pointers moving at different speeds.

O(n)

Merge Intervals

Sort and merge overlapping intervals into non-overlapping ones.

O(n log n)

Cyclic Sort

Place each number at its correct index. Find missing or duplicate numbers in O(n).

O(n)

Binary Search Variations

Lower/upper bound, search in rotated array, peak finding, and more.

O(log n)

Subsets / Backtracking

Generate all subsets, permutations, or combinations using backtracking.

O(2ⁿ)

Top K Elements

Use a min-heap of size K to efficiently find the K largest elements.

O(n log k)

Monotonic Stack

Maintain a monotonic stack for Next Greater Element type problems.

O(n)
Built by Gaurav Chaurasia • Back to Portfolio