Tiem Cong Nghe

Showing suggestions.

Opening the store's index…
↑↓ to move↵ to openesc to close
Tiem Cong Nghe search

Algorithms Visualized

Algorithms visualized: short animated videos you can step through, with the code in several languages.

  • 10 explainers
  • JavaScript · Python · Java · C++
  • 10 quizzes

10 algorithms

  • Featured

    Kruskal's Algorithm

    Build a minimum spanning tree by scanning edges from lightest to heaviest and keeping each one that does not close a cycle, checked with a union-find. Spanning forests, tie-breaking, and why the sort dominates the cost.

    Difficulty
    Medium
    Time
    O(E log E)
    Space
    O(V + E)
    • Video
    • Code in 4 languages
    • Quiz · 10 questions
  • MediumO(V + E)

    Topological Sort (Kahn's Algorithm)

    Put the tasks of a dependency graph in a valid order: repeatedly take what has no unfinished prerequisites, using in-degrees and a queue. Finds a cycle for free, and shows why many valid orders exist.

    • Video
    • Code
    • Quiz
  • EasyO(n²) worst, O(n) best

    Insertion Sort

    Grow a sorted prefix one value at a time, like sorting a hand of cards: take the next value, shift the bigger ones right, drop it into the gap. A stable, in-place sort that is O(n) on nearly sorted input and O(n²) in the worst case, and the small-run workhorse inside TimSort and introsort.

    • Video
    • Code
    • Quiz
  • MediumO(n log n)

    Heap Sort

    Treat the array as a binary tree, build a max-heap with siftDown, then keep swapping the biggest value to the end and repairing the shrinking heap. In place, O(n log n) in the worst case, O(1) extra space.

    • Video
    • Code
    • Quiz
  • EasyO(V + E)

    Graph Traversal: BFS and DFS

    Visit every vertex of a graph reachable from a starting point. BFS uses a queue and walks level by level; DFS uses a stack and dives deep first. Same code shape, one different container, and why that changes everything.

    • Video
    • Code
    • Quiz
  • EasyO(n²) worst, O(n) best

    Bubble Sort

    Sweep the array, swapping neighbours that are out of order, so the biggest value bubbles to the end each pass. A stable, in-place bubble sort that stops as soon as a sweep makes no swap: O(n) when sorted, O(n²) otherwise.

    • Video
    • Code
    • Quiz
  • MediumO(n log n)

    Merge Sort

    Cut the array in half, sort each half, then merge the two sorted halves in one pass. A stable top-down merge sort with one buffer shared by every merge: O(n log n) on every input, O(n) extra memory.

    • Video
    • Code
    • Quiz
  • EasyO(log n)

    Binary Search

    Find a value in a sorted array by checking the middle and throwing away the half that can't hold it — a million items in about 20 steps. Includes lowerBound, the form interviews actually ask for.

    • Video
    • Code
    • Quiz
  • MediumO((V + E) log V)

    Dijkstra's Algorithm

    Shortest paths from one starting point in a weighted graph: always finish the closest unfinished vertex next, using a priority queue. Distances, path reconstruction, and why negative edges break it.

    • Video
    • Code
    • Quiz
  • MediumO(n log n) avg, O(n²) worst

    Quick Sort

    Pick a pivot, push smaller values left and bigger values right, then sort each side the same way. In-place quick sort with Hoare partition, a median-of-three pivot and an O(log n) stack.

    • Video
    • Code
    • Quiz