Algorithm and Data Structure Visualizer
Watch classic algorithms run step by step on your own data, with colour highlights, a live pseudo-code line and counters for comparisons and swaps.
ทำงานในเบราว์เซอร์ของคุณ ไฟล์ไม่ออกจากอุปกรณ์ ดูวิธีตรวจสอบ
…
วิธีทำ
- 1Choose a topic
Pick Sorting, Graphs, Trees or Dynamic programming.
- 2Pick the algorithm
Select the algorithm or operation from the first menu.
- 3Enter input
Type values, edges, strings or items, or use Random.
- 4Play
Press Play and adjust the speed slider.
- 5Step through
Pause and use Back and Next or the arrow keys while you read the highlighted pseudo-code line.
- 6Read the result
The final step shows the sorted array, distances, traversal order or DP answer.
เกี่ยวกับเครื่องมือนี้
Algorithms are easier to understand when you can see them move. This visualizer records every step of an algorithm on input you choose and lets you play it like a video, pause it, or step forward and back with the arrow keys. Sorting shows bars that change colour as they are compared, swapped and fixed in place, with live counts of comparisons and writes. Graph algorithms draw your own weighted graph and colour nodes as they are queued, visited and finished, with distances for Dijkstra. Binary search trees grow node by node, and traversals light up in visiting order. Dynamic programming fills its table cell by cell and shows which cells each value depends on, then traces the answer path. Next to every animation the pseudo-code highlights the line being executed, which links the picture to the code you will write in an exam or interview.
Who this is for
Computer science students, bootcamp learners preparing for coding interviews, teachers who want a projector-friendly demo, and developers refreshing their memory of an algorithm before using it.
Sorting
Bubble, selection, insertion, merge, quicksort (Lomuto partition), heapsort and counting sort. Enter up to 60 numbers or use Random, Reversed or Nearly sorted to see best and worst cases. Colours: amber for compared, red for swapped or written, purple for the pivot or key, green for sorted, and a blue band for the merge or partition range.
Graphs
Write one edge per line as from to weight; tick Directed if needed. Choose breadth-first search, depth-first search, Dijkstra's shortest paths, Prim's minimum spanning tree or Kahn's topological sort and a start node. The frontier (queue or stack) is blue, the current node amber, finished nodes and tree edges green. Dijkstra warns about negative weights; topological sort reports cycles.
Trees
Insert values one by one into a binary search tree, search for a value along its path, delete a value (leaf, one child, or two children with the in-order successor), or traverse in-order, pre-order, post-order and level order.
Dynamic programming
Longest common subsequence and edit distance between two strings, 0/1 knapsack with weight:value items and a capacity, and the fewest-coins change problem. The current cell is orange, the cells it reads are blue, and after the last step the reconstruction path is green with the answer underneath.
Controls
Play, pause, first, last, back and next buttons, a step slider, seven speeds and keyboard shortcuts: space to play or pause, left and right arrows to step. Inputs are saved in your browser.
Worked example
Dijkstra from A on the sample graph with edges A–B 4, A–C 2, B–C 5, B–D 10, C–E 3, E–D 4, D–F 11 and E–F 9 finishes with distances B 4, C 2, E 5, D 9 and F 14: the path to D goes A–C–E–D (2 + 3 + 4) instead of the direct-looking A–B–D (14).
Limits
Inputs are capped (60 values, 40 tree nodes, strings of 16 characters, capacity 30) so the animations stay readable. Graph layout is a simple circle, so large graphs get crowded. The visualizer explains algorithms; it is not a benchmark of real running time.
ตัวอย่างพร้อมวิธีทำ
Dijkstra from A: distances B 4, C 2, E 5, D 9, F 14; the shortest path to D is A–C–E–D.
สรุปสั้น ๆ
- หมวดหมู่: นักพัฒนาและข้อมูล
- ทำงานในเบราว์เซอร์ ไม่ต้องสมัคร ไม่ต้องอัปโหลด
- ข้อมูลที่คุณกรอกอยู่บนอุปกรณ์ของคุณ
- มีภาษาอังกฤษ
- ตรวจสอบเนื้อหาล่าสุด:
- แหล่งข้อมูลทางการ: Cormen et al., Introduction to Algorithms, 4th edition (MIT Press)
คำถามที่พบบ่อย
Can I use my own data?
Yes. Every mode has inputs for numbers, edges, tree values, strings or items, and the animation is rebuilt as you type.
Which sorting algorithm is fastest?
For general data, merge sort, heapsort and quicksort run in O(n log n); insertion sort wins on nearly sorted small arrays. Compare the counters on the same input.
Why does Dijkstra not allow negative weights?
It finalises the closest node each round, which can be wrong when a negative edge appears later. Bellman–Ford handles negative weights.
How do I step backwards?
Press Back or the left arrow key; every step is recorded, so you can move freely.
Is the pseudo-code real code?
It is language-neutral pseudo-code in the style of textbooks; each step names the line it executes.
Does it work on a phone?
Yes. Controls wrap on small screens and the drawings scale to the screen width.
