# DSA Visualizer > Watch JavaScript solutions to data structure and algorithm problems run step by step, with every variable, array, tree, graph and pointer animated. Each page has the problem statement, a JavaScript solution and an interactive step-by-step visualization of it running. ## Algorithms - [Adjacency List](https://dsa-visualizer-gamma-six.vercel.app/q/adjacency-list): An adjacency list stores a graph as an array with one entry per vertex: adj[u] is the list of vertices you can reach from u in one step… - [Adjacency Matrix](https://dsa-visualizer-gamma-six.vercel.app/q/adjacency-matrix): An adjacency matrix stores a graph with n vertices as an n x n table: the cell in row u and column v is 1 when there is an edge from u to… - [AVL Tree](https://dsa-visualizer-gamma-six.vercel.app/q/avl-tree): An AVL tree is a self-balancing binary search tree: after every insertion it checks each node on the way back up and, if the two subtrees… - [B-Tree](https://dsa-visualizer-gamma-six.vercel.app/q/b-tree): A B-tree is a balanced search tree whose nodes hold many sorted keys and have many children. All leaves sit at the same depth, and every… - [Binary Search](https://dsa-visualizer-gamma-six.vercel.app/q/binary-search): Binary search finds a target in a sorted array by repeatedly looking at the middle element and throwing away the half that cannot contain… - [Breadth-First Search (BFS)](https://dsa-visualizer-gamma-six.vercel.app/q/bfs): Breadth-first search (BFS) explores a graph level by level from a source vertex: first the source, then everything one edge away, then… - [BST Deletion](https://dsa-visualizer-gamma-six.vercel.app/q/bst-deletion): Deleting a node from a binary search tree must remove the value while keeping the left-smaller / right-larger ordering intact. There are… - [BST Insertion](https://dsa-visualizer-gamma-six.vercel.app/q/bst-insertion): A binary search tree (BST) keeps its values ordered: for every node, everything in the left subtree is smaller and everything in the right… - [BST Search](https://dsa-visualizer-gamma-six.vercel.app/q/bst-search): Searching a binary search tree uses the ordering of the tree to throw away half of the remaining values at each step. This sample builds a… - [Bubble Sort](https://dsa-visualizer-gamma-six.vercel.app/q/bubble-sort): Bubble sort orders an array by repeatedly comparing neighbouring elements and swapping them when they are in the wrong order. After each… - [Circular Linked List](https://dsa-visualizer-gamma-six.vercel.app/q/circular-linked-list): A circular linked list is a linked list whose last node points back to the first instead of to null, so following next pointers goes… - [Circular Queue](https://dsa-visualizer-gamma-six.vercel.app/q/circular-queue): A circular queue (ring buffer) is a fixed-capacity FIFO queue whose indices wrap around the end of the array using modulo arithmetic. It… - [Compare Two Linked Lists](https://dsa-visualizer-gamma-six.vercel.app/q/compare-linked-lists): Compare two linked lists node by node and return -1 if the first is smaller, 0 if they are equal and 1 if the first is larger, using… - [Decision Tree Evaluation](https://dsa-visualizer-gamma-six.vercel.app/q/decision-tree): A decision tree predicts an answer by asking a sequence of yes/no questions about the input. Each internal node tests one feature against… - [Depth-First Search (DFS)](https://dsa-visualizer-gamma-six.vercel.app/q/dfs): Depth-first search (DFS) explores a graph by going as deep as possible along one path, and only backing up when it hits a dead end. It… - [Deque (Double-Ended Queue)](https://dsa-visualizer-gamma-six.vercel.app/q/deque): A deque (double-ended queue, pronounced "deck") lets you insert and remove elements at both ends in O(1). It generalizes both the stack… - [Diameter of a Binary Tree](https://dsa-visualizer-gamma-six.vercel.app/q/tree-diameter): The diameter of a tree is the number of edges on the longest path between any two nodes. The path may or may not pass through the root. It… - [Dijkstra's Shortest Path](https://dsa-visualizer-gamma-six.vercel.app/q/dijkstra): Dijkstra's algorithm finds the shortest distance from one source vertex to every other vertex in a graph whose edge weights are all… - [Doubly Linked List](https://dsa-visualizer-gamma-six.vercel.app/q/doubly-linked-list): A doubly linked list is a chain of nodes where every node knows both its successor (next) and its predecessor (prev). That second pointer… - [Expression Syntax Tree (Parse and Evaluate)](https://dsa-visualizer-gamma-six.vercel.app/q/syntax-tree): An abstract syntax tree (AST) represents the structure of an expression or program: operators become internal nodes and operands become… - [Fenwick Tree (Binary Indexed Tree)](https://dsa-visualizer-gamma-six.vercel.app/q/fenwick-tree): A Fenwick tree (binary indexed tree, BIT) keeps prefix sums of an array that keeps changing. Both "add delta to nums[i]" and "sum of… - [Heap Sort](https://dsa-visualizer-gamma-six.vercel.app/q/heap-sort): Heap sort sorts an array in place using a binary max-heap. It first rearranges the array into a max-heap, then repeatedly swaps the… - [Huffman Coding](https://dsa-visualizer-gamma-six.vercel.app/q/huffman-coding): Huffman coding builds the shortest possible prefix-free binary code for a set of symbols with known frequencies: frequent characters get… - [Inorder Traversal](https://dsa-visualizer-gamma-six.vercel.app/q/inorder-traversal): Inorder traversal visits the left subtree, then the node, then the right subtree. On a binary search tree it produces the values in sorted… - [Insertion Sort](https://dsa-visualizer-gamma-six.vercel.app/q/insertion-sort): Insertion sort grows a sorted prefix one element at a time. It takes the next element, slides it left past every larger value, and drops… - [Kruskal's Minimum Spanning Tree](https://dsa-visualizer-gamma-six.vercel.app/q/kruskal-mst): Kruskal's algorithm builds a minimum spanning tree (MST) of a weighted, undirected graph: n - 1 edges that connect every vertex with the… - [Level Order Traversal](https://dsa-visualizer-gamma-six.vercel.app/q/level-order-traversal): Level-order traversal visits a binary tree one level (depth) at a time, from the root downwards and from left to right inside each level… - [Linear Search](https://dsa-visualizer-gamma-six.vercel.app/q/linear-search): Linear search finds a target value in an array by checking the elements one at a time, from the first to the last. It returns the index of… - [Lowest Common Ancestor of a Binary Tree](https://dsa-visualizer-gamma-six.vercel.app/q/lowest-common-ancestor): The lowest common ancestor (LCA) of two nodes p and q in a rooted tree is the deepest node that has both of them as descendants (a node… - [Merge Sort](https://dsa-visualizer-gamma-six.vercel.app/q/merge-sort): Merge sort is a divide-and-conquer sorting algorithm: it splits the array in half, sorts each half recursively, and then merges the two… - [Merge Two Sorted Lists](https://dsa-visualizer-gamma-six.vercel.app/q/merge-two-sorted-lists): Merge two sorted linked lists into one sorted list by relinking their existing nodes. The lists are passed as arrays, turned into nodes… - [Morris Inorder Traversal](https://dsa-visualizer-gamma-six.vercel.app/q/morris-traversal): Morris traversal performs an inorder walk of a binary tree using O(1) extra space: no recursion and no stack. It does this by temporarily… - [Postfix Expression Evaluation](https://dsa-visualizer-gamma-six.vercel.app/q/postfix-evaluation): Postfix notation (reverse Polish notation) writes the operator after its operands: 2 3 + means 2 + 3. It needs no parentheses and no… - [Postorder Traversal](https://dsa-visualizer-gamma-six.vercel.app/q/postorder-traversal): Postorder traversal visits the left subtree, then the right subtree, and the node itself last. Every node is therefore processed after all… - [Prefix Expression Evaluation](https://dsa-visualizer-gamma-six.vercel.app/q/prefix-evaluation): Prefix notation (Polish notation) writes the operator before its operands: + 2 3 means 2 + 3. Like postfix, it needs no parentheses. A… - [Preorder Traversal](https://dsa-visualizer-gamma-six.vercel.app/q/preorder-traversal): Preorder traversal visits every node of a binary tree in the order node, left subtree, right subtree. It is a depth-first walk that… - [Prim's Minimum Spanning Tree](https://dsa-visualizer-gamma-six.vercel.app/q/prim-mst): Prim's algorithm builds a minimum spanning tree (MST) of a connected, weighted, undirected graph: a set of n - 1 edges that connects every… - [Priority Queue (Min-Heap)](https://dsa-visualizer-gamma-six.vercel.app/q/priority-queue): A priority queue is a queue where each element has a priority and the element with the highest priority leaves first, not the oldest. This… - [Queue (Array Implementation)](https://dsa-visualizer-gamma-six.vercel.app/q/queue-array): A queue is a collection that follows FIFO (first in, first out): elements leave in the order they arrived. This is the single-ended queue… - [Queue (Linked List Implementation)](https://dsa-visualizer-gamma-six.vercel.app/q/queue-linked-list): A queue is a FIFO (first in, first out) collection. This version stores the elements in a singly linked list with two references: head… - [Quick Sort](https://dsa-visualizer-gamma-six.vercel.app/q/quick-sort): Quick sort is a divide-and-conquer sorting algorithm. It picks a pivot, rearranges the array so that smaller values are on its left and… - [Red-Black Tree](https://dsa-visualizer-gamma-six.vercel.app/q/red-black-tree): A red-black tree is a binary search tree that keeps itself balanced by painting every node red or black and repairing the colors (plus at… - [Reverse Linked List (Recursive)](https://dsa-visualizer-gamma-six.vercel.app/q/reverse-linked-list-recursive): Reverse a singly linked list recursively: given the head of a list, return the head of the same nodes in reverse order, by reversing the… - [Segment Tree (Range Sum)](https://dsa-visualizer-gamma-six.vercel.app/q/segment-tree): A segment tree answers range queries (here: the sum of nums[l..r]) and point updates in O(log n) each. Every node stores the answer for… - [Selection Sort](https://dsa-visualizer-gamma-six.vercel.app/q/selection-sort): Selection sort builds the sorted array from left to right. In each round it scans the unsorted part to find the smallest element and swaps… - [Serialize and Deserialize a Binary Tree](https://dsa-visualizer-gamma-six.vercel.app/q/serialize-deserialize-tree): Serialization turns an in-memory tree into a flat string you can store or send; deserialization rebuilds an identical tree from that… - [Singly Linked List](https://dsa-visualizer-gamma-six.vercel.app/q/singly-linked-list): A singly linked list stores a sequence as a chain of nodes, where each node holds a value and a single next pointer to the following node… - [Stack (Array Implementation)](https://dsa-visualizer-gamma-six.vercel.app/q/stack-array): A stack is a collection that follows LIFO (last in, first out): the most recently added element is the first one removed. This array… - [Stack (Linked List Implementation)](https://dsa-visualizer-gamma-six.vercel.app/q/stack-linked-list): A stack is a LIFO (last in, first out) collection. This version stores the elements in a singly linked list where the head is the top of… - [Topological Sort (Kahn's Algorithm)](https://dsa-visualizer-gamma-six.vercel.app/q/topological-sort): A topological sort lines up the vertices of a directed acyclic graph (DAG) so that for every edge u -> v, vertex u comes before v. This… - [Tree Isomorphism (Flip Equivalence)](https://dsa-visualizer-gamma-six.vercel.app/q/tree-isomorphism): Two trees are isomorphic when one can be turned into the other by relabeling or reordering. This sample solves the common binary-tree… - [Trie (Prefix Tree)](https://dsa-visualizer-gamma-six.vercel.app/q/trie): A trie (prefix tree, from retrieval) stores a set of strings by sharing their common prefixes: each edge is one character, and a path from… ## Practice problems - [Contains Duplicate](https://dsa-visualizer-gamma-six.vercel.app/q/contains-duplicate): Contains Duplicate Problem Statement Given an integer array nums, determine whether any element appears more than once. Return true if at… - [Design Twitter](https://dsa-visualizer-gamma-six.vercel.app/q/design-twitter): Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and see the 10 most recent tweets in the… - [Valid Anagrams](https://dsa-visualizer-gamma-six.vercel.app/q/valid-anagrams): Valid Anagram Problem Statement Given two strings s and t, determine whether they are anagrams of each other. Two strings are anagrams if… ## Optional - [Full content](https://dsa-visualizer-gamma-six.vercel.app/llms-full.txt): every problem statement and solution in one file - [Sitemap](https://dsa-visualizer-gamma-six.vercel.app/sitemap.xml): all pages