ALGORITHM VISUALIZATION & CODE TRACER

Master DSA with Algorithm Visualization

Step through code execution frame-by-frame. Watch pointers move, trees balance, and windows slide — visualize algorithms intuitively and ace technical interviews.

99+Visualizers
8Categories
LiveFrame Playback
Built for engineers preparing for top tech interviews
GoogleMetaamazonMicrosoftAppleNetflix
INTERACTIVE PREVIEW

Experience the "Aha!" moment in real-time.

Step through this binary search algorithm below. Watch how the execution pointer, midpoint index calculations, and variable watches stay synchronized at every step.

binary_search.js
Step 1 / 7
1
function binarySearch(nums, target) {
2
  let left = 0;
3
  let right = nums.length - 1;
4
  while (left <= right) {
5
    let mid = Math.floor((left + right) / 2);
6
    if (nums[mid] === target) return mid;
7
    if (nums[mid] < target) left = mid + 1;
8
    else right = mid - 1;
9
  }
10
  return -1;
11
}
Variables & Memory
left0
right5
mid-
nums[mid]-
statusinit
Initialize search pointers. Array: [1, 3, 5, 7, 9, 11], target = 7
Step forward to advance execution

Explore Algorithm Visualizers

Filter by data structure category, difficulty, or search specific algorithms.

99 algorithm visualizers available
LL
Linked Lists
Medium

Add Two Numbers

Add two numbers represented by linked lists in reverse digit order, simulating column-by-column addition with carry.

Linked ListMathTwo PointersSimulation
ST
Stack
Medium

Asteroid Collision

Simulate asteroid collisions where positive asteroids move right and negative move left. Smaller asteroids explode upon impact.

StackSimulationArray
BT
Backtracking
Medium

Backtracking: Decision Tree & Constraints

Explore the universal backtracking template: watch the state space tree expand, witness constraint pruning terminate invalid branches early, and trace how choices are systematically undone.

BacktrackingDecision TreePruningRecursionCombinationsState Space
TR
Trees & BST
Easy

Balanced Binary Tree

Determine if a binary tree is height-balanced (depth of the two subtrees of every node never differs by more than 1).

DFSBinary TreeRecursionTree HeightTree Property
ST
Stack
Easy

Baseball Game

Keep score for a baseball game by processing score records, invalidations, doubling, and additions using a stack.

StackArraySimulationLeetCode 682
BT
Backtracking
Medium

Beautiful Arrangement

Count the number of permutations where either the number at position i is divisible by i, or i is divisible by the number, using recursive backtracking and divisibility pruning.

BacktrackingBit ManipulationRecursionPermutationsMath
TR
Trees & BST
Medium

Binary Tree Level Order Traversal

Traverse binary tree nodes level-by-level from left to right using a FIFO queue (BFS).

BFSBinary TreeQueueLevel Order
TR
Trees & BST
Hard

Binary Tree Maximum Path Sum

Find the maximum path sum along any sequence of nodes in a binary tree using bottom-up postorder DFS (ignoring negative subtrees).

DFSBinary TreeRecursionPath SumHardPostorder
BT
Backtracking
Easy

Binary Tree Paths

Find all root-to-leaf paths in a binary tree in any order using depth-first search and backtracking.

BacktrackingTreeDepth-First SearchBinary Tree
TR
Trees & BST
Medium

Binary Tree Right Side View

Return the values of the nodes you can see ordered from top to bottom when standing on the right side of the binary tree.

BFSBinary TreeQueueRight ViewLevel Order
TR
Trees & BST
Medium

Binary Tree Zigzag Level Order Traversal

Traverse binary tree levels alternating directions (left-to-right on even levels, right-to-left on odd levels).

BFSBinary TreeQueueZigzagLevel Order
ST
Stack
Medium

Car Fleet

Calculate the number of car fleets that will arrive at the target destination using arrival times and a monotonic stack.

StackSortingMonotonic Stack
AR
Arrays & Hashing
Easy

Check if Every Row and Column Contains All Numbers

An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive). Check validity using row and column hash sets.

ArrayHash TableMatrix
RC
Recursion & DP
Easy

Climbing Stairs (1D DP)

Calculate distinct ways to climb n stairs using top-down memoization, filling a 1D DP table.

Dynamic ProgrammingMemoizationFibonacci1D DP
RC
Recursion & DP
Easy

Climbing Stairs (Recursion Tree)

Visualize the recursive decision tree for climbing n stairs taking 1 or 2 steps at a time.

Recursion TreeDecision TreeFibonacciCall Stack
BT
Backtracking
Medium

Combination Sum

Find all unique combinations of candidate numbers that sum to target using recursive backtracking on the decision tree.

BacktrackingRecursionArrayDecision TreeLeetCode 39
BT
Backtracking
Medium

Combination Sum II

Find all unique combinations in candidates that sum to target. Each number may only be used once, using duplicate skipping and branch pruning.

BacktrackingRecursionArrayDecision TreeLeetCode 40
BT
Backtracking
Medium

Combinations

Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n] using recursive backtracking on the decision tree.

BacktrackingRecursionCombinationsDecision TreeLeetCode 77
AR
Arrays & Hashing
Easy

Concatenation of Array

Given an integer array nums of length n, create and return an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n.

ArraySimulationTwo Pointers
AR
Arrays & Hashing
Medium

Container With Most Water

Find two lines that together with the x-axis form a container containing the most water using an optimal O(n) two-pointer inward scan.

Two PointersArrayGreedyGraphLeetCode 11
AR
Arrays & Hashing
Easy

Contains Duplicate

Detect duplicate elements in an array using an instant-lookup hash set.

Hash SetLookupFrequency
SW
Sliding Window
Easy

Contains Duplicate II

Determine if there are two distinct indices i and j such that nums[i] == nums[j] and abs(i - j) <= k using a sliding window hash set.

Sliding WindowHash SetArray
TR
Trees & BST
Medium

Count Complete Tree Nodes

Count nodes in a complete binary tree in less than O(n) time by comparing left and right subtree heights.

DFSBinary TreeBinary SearchTree HeightComplete Tree
TR
Trees & BST
Medium

Count Good Nodes in Binary Tree

Count the number of 'good' nodes in a binary tree (a node X is good if on the path from root to X there are no nodes with value greater than X).

DFSBinary TreeRecursionPath MaximumTree Traversal
ST
Stack
Medium

Daily Temperatures

Find the number of days you have to wait after the i-th day to get a warmer temperature using a monotonic decreasing stack.

Monotonic StackArray
AR
Arrays & Hashing
Easy

Design HashSet

Design a HashSet without using any built-in hash table libraries, demonstrating hashing (key % size) and collision resolution via separate chaining in dynamic buckets.

HashSetHashingSeparate ChainingCollision ResolutionBuckets
TR
Trees & BST
Easy

Diameter of Binary Tree

Compute the diameter (longest path between any two nodes) by finding max(leftDepth + rightDepth) at each node using postorder DFS.

DFSBinary TreeRecursionTree HeightPath
AR
Arrays & Hashing
Medium

Dutch National Flag (Sort Colors)

Sort an array of 0s, 1s, and 2s in-place in linear time using Dijkstra's 3-way partitioning Dutch National Flag algorithm.

Two PointersSortingArrayIn-Place
ST
Stack
Medium

Evaluate Reverse Polish Notation

Evaluate arithmetic expressions written in Reverse Polish Notation (postfix) using a LIFO operand stack.

StackArrayMathPostfix Evaluation
BS
Binary Search
Medium

Find Minimum in Rotated Sorted Array

Find the minimum element in a sorted rotated array in O(log n) time by comparing nums[mid] to nums[right].

Binary SearchRotated ArrayInflection Point
BT
Backtracking
Medium

Generate Parentheses

Generate all combinations of well-formed parentheses using recursive backtracking with open and close count pruning.

BacktrackingRecursionStringDecision TreeLeetCode 22
AR
Arrays & Hashing
Medium

Group Anagrams

Group strings together using sorted character keys in a hash map.

Hash MapSortingCategorization
BS
Binary Search
Easy

Guess Number Higher or Lower

Binary search to guess a secret picked number in range [1..n] in O(log n) using pre-defined guess() API feedback.

Binary SearchInteractive GameLeetCode 374
LL
Linked Lists
Easy

Linked List Cycle

Detect whether a linked list contains a cycle using Floyd's Tortoise and Hare algorithm.

Linked ListTwo PointersCycle DetectionFloyd's Algorithm
TR
Trees & BST
Easy

Binary Tree Inorder Traversal

Visit binary tree nodes in Left -> Root -> Right order producing sorted order for Binary Search Trees.

DFSBinary TreeInorderBST
TR
Trees & BST
Easy

Invert Binary Tree

Invert a binary tree by recursively swapping the left and right child subtrees of every node.

DFSBinary TreeRecursionMirror
AR
Arrays & Hashing
Easy

Valid Anagram

Check if two strings contain identical character frequency distributions.

Hash MapStringFrequency
BS
Binary Search
Medium

Koko Eating Bananas

Binary search on integer speed k in range [1 .. max(piles)] to find the minimum eating speed to finish all piles within h hours.

Binary Search on AnswerMonotonic Predicate
TR
Trees & BST
Medium

Kth Smallest Element in a BST

Find the kth smallest element (1-indexed) in a Binary Search Tree (BST) using in-order DFS traversal step counting.

BSTBinary Search TreeDFSInorder TraversalRecursion
BT
Backtracking
Medium

Letter Combinations of a Phone Number

Generate all possible letter combinations that the input phone digits could represent using keypad mapping and recursive backtracking.

BacktrackingRecursionStringDecision TreeHash TableLeetCode 17
AR
Arrays & Hashing
Medium

Longest Consecutive Sequence

Find length of longest contiguous integer streak in O(n) using a hash set.

Hash SetStreakO(n)
SW
Sliding Window
Medium

Longest Repeating Character Replacement

Find the length of the longest substring containing the same letter you can get after performing at most k character replacements using a dynamic sliding window.

Sliding WindowTwo PointersFrequency Map
TR
Trees & BST
Medium

Lowest Common Ancestor of a Binary Search Tree

Find the lowest common ancestor (LCA) node of two given nodes p and q in a Binary Search Tree (BST) using value comparisons.

BSTBinary Search TreeDFSTree TraversalAncestor
TR
Trees & BST
Easy

Maximum Depth of Binary Tree

Find the maximum depth (height) of a binary tree by calculating 1 + max(leftDepth, rightDepth) recursively.

DFSBinary TreeRecursionTree Height
TR
Trees & BST
Medium

Maximum Width of Binary Tree

Calculate the maximum width among all levels of a binary tree by assigning 0-indexed position coordinates and normalizing each level against its starting index.

BFSBinary TreeQueueTree WidthLevel Order Traversal
AR
Arrays & Hashing
Medium

Merge Sort (Sort an Array)

Sort an array of integers in ascending order using divide-and-conquer Merge Sort with O(n log n) time complexity.

Divide and ConquerMerge SortRecursionSortingArray
AR
Arrays & Hashing
Easy

Merge Sorted Array

Merge two sorted integer arrays into nums1 as one sorted array using two pointers and an auxiliary merge buffer.

Two PointersArraySorting
AR
Arrays & Hashing
Easy

Merge Strings Alternately

Merge characters from word1 and word2 in alternating order, appending any remaining suffix characters.

Two PointersStringSimulation
LL
Linked Lists
Easy

Merge Two Sorted Lists

Merge two sorted linked lists into a single sorted list by splicing together node pointers in O(n + m) time.

Linked ListTwo PointersSimulation
LL
Linked Lists
Easy

Middle of the Linked List

Find the middle node of a singly linked list using fast and slow pointers.

Linked ListTwo PointersFast & Slow Pointers
HP
Heap / Priority Queue
Medium

Min Heap (Heapify Up & Down)

Complete binary min-heap implementation visualizing _heapifyUp() on insertion and _heapifyDown() on root extraction across both binary tree and 0-indexed array representations.

Min HeapBinary HeapHeapify UpHeapify DownPriority QueueComplete Binary Tree
ST
Stack
Medium

Min Stack

Design a stack supporting push, pop, top, and retrieving the minimum element in constant O(1) time using an auxiliary monotonic min-tracker stack.

StackDesignMonotonic StackConstant Time
SW
Sliding Window
Medium

Minimum Size Subarray Sum

Find the minimal length of a contiguous subarray of which the sum is greater than or equal to target using a dynamic sliding window.

ArrayBinary SearchSliding WindowPrefix Sum
AR
Arrays & Hashing
Easy

Move Zeroes

Move all zeros in an array to the end in-place while maintaining the relative order of the non-zero elements using two pointers.

Two PointersArrayIn-Place
ST
Stack
Easy

Next Greater Element I

Find the next greater element for each number in nums1 within nums2 using a monotonic stack and hash map.

Monotonic StackHash MapArray
ST
Stack
Medium

Next Greater Element II

Find the next greater numeric element for every number in a circular integer array using a monotonic decreasing stack over two passes.

StackMonotonic StackArrayCircular Array
LL
Linked Lists
Medium

Odd Even Linked List

Group all nodes with odd indices together followed by nodes with even indices in O(1) space and O(n) time.

Linked ListTwo PointersIn-Place
ST
Stack
Medium

Online Stock Span

Calculate the span of stock prices in an online stream using a monotonic decreasing stack tracking [price, span] pairs.

StackMonotonic StackDesignData Stream
LL
Linked Lists
Easy

Palindrome Linked List

Determine if a singly linked list is a palindrome in O(n) time and O(1) space using fast/slow pointers and in-place reversal.

Linked ListTwo PointersFast & Slow PointersIn-Place
BT
Backtracking
Medium

Palindrome Partitioning

Partition a string such that every substring of the partition is a palindrome using backtracking and two-pointer palindrome validation.

BacktrackingTwo PointersStringRecursionDynamic Programming
LL
Linked Lists
Medium

Partition List

Partition a linked list such that all nodes less than x come before nodes greater than or equal to x, preserving relative order.

Linked ListTwo PointersPartition
TR
Trees & BST
Easy

Path Sum

Determine if the binary tree has a root-to-leaf path such that adding up all values along the path equals targetSum.

DFSBinary TreeRecursionPath SumBacktracking
TR
Trees & BST
Medium

Path Sum II

Find all unique root-to-leaf paths where the sum of the node values equals targetSum using DFS backtracking.

DFSBinary TreeRecursionBacktrackingAll Paths
BT
Backtracking
Medium

Permutations

Generate all possible permutations of an array of distinct integers using recursive backtracking and a visited set.

BacktrackingRecursionPermutationsDecision TreeLeetCode 46
TR
Trees & BST
Easy

Binary Tree Postorder Traversal

Visit binary tree nodes in Left -> Right -> Root order for bottom-up calculation and subtree evaluation.

DFSBinary TreePostorderBottom-up
TR
Trees & BST
Easy

Binary Tree Preorder Traversal

Visit binary tree nodes in Root -> Left -> Right order using DFS recursion and call stack unwinding.

DFSBinary TreeRecursionPreorder
AR
Arrays & Hashing
Medium

Range Sum Query 2D - Immutable

Precompute a 2D prefix sum matrix in O(m · n) time to evaluate any submatrix sum query in O(1) time using the 2D Inclusion-Exclusion Principle.

Prefix SumMatrixDesignInclusion-Exclusion
AR
Arrays & Hashing
Easy

Range Sum Query - Immutable

Precompute prefix sums in O(n) to evaluate contiguous subarray sum queries in constant O(1) time.

Prefix SumArrayDesign
ST
Stack
Easy

Remove All Adjacent Duplicates In String

Repeatedly remove adjacent, duplicate character pairs from a string using a LIFO stack until no duplicates remain.

StackStringAdjacent DuplicatesSimulation
LL
Linked Lists
Easy

Remove Duplicates from Sorted List

Delete all duplicate elements from a sorted singly linked list so each element appears only once.

Linked ListTwo Pointers
LL
Linked Lists
Medium

Remove Nth Node From End of List

Remove the n-th node from the end of the list and return its head using a one-pass two-pointer approach with a dummy node.

Linked ListTwo PointersDummy Node
LL
Linked Lists
Medium

Reorder List

Reorder the list to L0 → Ln → L1 → Ln-1 → L2 → Ln-2 by finding the middle, reversing the second half, and merging both halves.

Linked ListTwo PointersReversalMerge
BT
Backtracking
Medium

Restore IP Addresses

Generate all possible valid IPv4 addresses by partitioning a string into four octets (0-255 without leading zeros) using recursive backtracking.

BacktrackingStringRecursionPruning
LL
Linked Lists
Easy

Reverse Linked List

Reverse a singly linked list iteratively in-place by reversing the next pointer of each node.

Linked ListTwo PointersIterativeIn-Place
LL
Linked Lists
Medium

Reverse Linked List II

Reverse a singly linked list from position left to position right in a single pass.

Linked ListTwo PointersIterativeIn-Place
RC
Recursion & DP
Easy

Reverse String

Reverse a character array in-place using recursive two-pointer swap and call stack unwinding.

Call StackRecursionTwo Pointers
LL
Linked Lists
Medium

Rotate List

Rotate the linked list to the right by k places by connecting the tail to head and severing at (length - k % length).

Linked ListTwo PointersCircular List
TR
Trees & BST
Easy

Same Tree

Check if two binary trees are structurally identical and have the same node values using simultaneous DFS recursion.

DFSBinary TreeRecursionTree Comparison
BS
Binary Search
Medium

Search a 2D Matrix

Treat an m x n row-sorted matrix as a virtual 1D sorted array [0 .. m*n - 1] and perform binary search.

Binary Search2D MatrixCoordinate Mapping
BS
Binary Search
Easy

Search Insert Position

Find target index or insertion position in sorted array using binary search [left, right].

Binary SearchRange Halving
BS
Binary Search
Medium

Search in Rotated Sorted Array

Find target index in a rotated sorted array in O(log n) time by finding the pivot (minimum element) and binary searching the target segment.

Binary SearchRotated ArrayTwo Phase
BS
Binary Search
Medium

Capacity To Ship Packages Within D Days

Binary search on candidate ship capacity in range [max(weights) .. sum(weights)] to find minimum capacity feasible within D days.

Binary Search on AnswerGreedy Simulation
ST
Stack
Medium

Simplify Path

Convert an absolute Unix-style file path into its canonical simplified form using a LIFO stack to manage directory navigation, parent traversals, and redundant slashes.

StackStringUnix PathSimulationLeetCode 71
LL
Linked Lists
Medium

Sort List

Sort a linked list in O(n log n) time using top-down Merge Sort with divide-and-conquer recursion.

Linked ListMerge SortDivide and ConquerRecursion
AR
Arrays & Hashing
Easy

Squares of a Sorted Array

Square numbers and sort in O(n) time using opposing two pointers.

Two PointersSorted Array
BT
Backtracking
Medium

Subsets

Generate all possible subsets (the power set) of a distinct integer array using recursive backtracking on the decision tree.

BacktrackingRecursionPower SetCombinationsDecision Tree
BT
Backtracking
Medium

Subsets II

Generate all unique subsets from an integer array that may contain duplicates using sorting, duplicate skipping, and recursive backtracking.

BacktrackingRecursionArrayDecision TreeLeetCode 90
TR
Trees & BST
Easy

Subtree of Another Tree

Check if binary tree subRoot is a subtree of root with identical structure and node values.

DFSBinary TreeRecursionTree ComparisonSubtree
TR
Trees & BST
Medium

Sum Root to Leaf Numbers

Calculate the total sum of all numbers formed along root-to-leaf paths (each path represents a decimal number).

DFSBinary TreeRecursionPath Numbers
LL
Linked Lists
Medium

Swap Nodes in Pairs

Swap every two adjacent nodes in a linked list and return its head without modifying node values.

Linked ListRecursionPointer Manipulation
TR
Trees & BST
Easy

Symmetric Tree

Check whether a binary tree is a mirror of itself (symmetric around its center) using simultaneous dual-pointer DFS recursion.

DFSBinary TreeRecursionMirrorSymmetry
AR
Arrays & Hashing
Medium

3Sum

Find all unique triplets that sum to zero with sorting and two pointers.

Two PointersSortingDuplicate Handling
AR
Arrays & Hashing
Easy

Two Sum

Find indices of two numbers that add up to target using a single-pass hash map.

Hash MapArrayComplement
AR
Arrays & Hashing
Medium

Two Sum II (Sorted Array)

Find two numbers in a 1-indexed sorted array that add up to a target number using opposing two pointers in O(n) time and O(1) space.

Two PointersArrayBinary SearchSorted Array
AR
Arrays & Hashing
Easy

Valid Palindrome II

Determine if a string can be a palindrome after deleting at most one character using two pointers.

Two PointersStringGreedy
ST
Stack
Easy

Valid Parentheses

Determine if an input string containing '(', ')', '{', '}', '[' and ']' is valid using a LIFO stack.

StackStringMatching
AR
Arrays & Hashing
Medium

Valid Sudoku

Validate a 9x9 Sudoku board checking rows, columns, and 3x3 subgrids.

Hash SetMatrixValidation
TR
Trees & BST
Medium

Validate Binary Search Tree

Determine if a binary tree is a valid Binary Search Tree (BST) where every node satisfies min < node.val < max recursively.

BSTBinary Search TreeDFSRecursionRange Bounds
BT
Backtracking
Medium

Word Search

Determine if a target word exists in a 2D grid of characters by constructing a path of adjacent cells without reusing any cell.

BacktrackingMatrixDFSRecursion
01/WHY VISUAL TRACING WORKS

The definitive visual guide to Data Structures & Algorithms.

Staring at static code blocks or memorizing LeetCode solutions often fails when interviewers tweak problem constraints. TraceDSA offers true step-by-step algorithm visualization so you build deep mental models for code execution.

Frame-by-Frame Playback

Pause, step forward, and rewind execution. Inspect how variables, pointers, and memory mutate at each discrete algorithmic state.

Real Code Execution Tracing

Connect high-level visuals directly to executable code. A synchronized code pointer highlights the exact line executing in real-time.

Visual Time & Space Complexity

Stop memorizing static Big-O cheat sheets. Watch how operation counts and stack allocations scale dynamically with input size.

Call Stack & Recursion Trees

Demystify complex recursive algorithms, tree traversals, and dynamic programming memoization with visual recursion frame stacks.

Custom Input Playground

Feed your own custom arrays, binary search trees, and graphs into any visualizer to test edge cases and interview variations.

Core DSA Pattern Mastery

Master Two Pointers, Sliding Window, Monotonic Stack, BFS/DFS, and Binary Search patterns asked by Google, Meta, and Amazon.

FREQUENTLY ASKED QUESTIONS

Common questions about TraceDSA

Everything you need to know about our interactive algorithm visualizers and learning platform.

An algorithm visualizer is an interactive web tool that simulates data structure mutations and algorithm execution step-by-step. Instead of reading abstract theory or watching static videos, developers can see pointers move, trees rebalance, and memory buffers mutate in real-time.