Data Structures

Data Structures

Applications covers sorting, searching, ranges, trees, and hashing. Advanced covers divide and conquer, heaps, and shortest paths.

Applications 12

Practice sorting, searching, range techniques, trees, and hashing.

  1. Sorting at a Glance

    Race seven sorting algorithms on the same array and compare their work, complexity, and use cases.

  2. Bubble Sort

    Repeatedly compare adjacent values and swap them to move the largest remaining value to the end.

  3. Selection Sort

    Repeatedly select the smallest remaining value and swap it into the next position.

  4. Insertion Sort

    Take values one at a time and insert them into the sorted prefix.

  5. Counting Sort

    Count occurrences to calculate positions without comparing values to each other.

  6. Binary Search

    Halve the candidates in a sorted array; explore exact search, lower and upper bounds, and parametric search.

  7. Two Pointers

    Move two pointers monotonically to turn some quadratic searches into linear scans.

  8. Sliding Window

    Maintain information about a contiguous range by updating only values entering and leaving it.

  9. Prefix sums

    Precompute prefix totals to answer a range-sum query with one subtraction.

  10. Binary Search Tree

    Insert, find, and delete values; see how tree shape changes and why a skewed tree is slow.

  11. Hash Tables

    Map a key directly to a bucket and explore how collisions are handled.

  12. BFS and DFS

    Explore the same graph breadth-first and depth-first to see how queues and stacks change the visiting order.

Advanced 4

Explore divide and conquer, heaps, shortest paths, and combined algorithms.

  1. Quick Sort

    Partition around a pivot, then recursively sort both sides.

  2. Merge Sort

    Recursively split the array, then merge sorted halves in a divide-and-conquer algorithm.

  3. Heap Sort

    Build a max heap, then repeatedly move the largest value to the end.

  4. Dijkstra's Shortest Paths

    Finalize the closest unsettled node and relax distances to its neighbors.