cswork / libraryOpen practice workspace

READ. UNDERSTAND. PRACTICE.

Algorithm tutorials

Explore algorithm tutorials, coding and system design questions, interview experiences, and computer science study guides.

100 resources · Page 5 of 5

  1. Algorithm tutorials

    Trie (Prefix Tree)

    A trie stores strings character by character so that shared prefixes share nodes. Insert, lookup and prefix queries cost O(length); it powers autocomplete, wildcard search, grid word search and, as a binary trie, maximum-XOR queries.

  2. Algorithm tutorials

    Two Pointers and Sliding Window

    Linear-time scans with two moving indices: opposite-end pointers on sorted arrays, variable and fixed sliding windows, the 'at most K' counting trick, subsequence matching, and fast/slow pointers for cycles.

  3. Algorithm tutorials

    Union-Find (Disjoint Set Union)

    Track merging groups with near-constant-time find and union using path compression and union by size. Used for dynamic connectivity, cycle detection, Kruskal's MST and weighted relation problems.

  4. Algorithm tutorials

    Z-Function (Z-Algorithm)

    z[i] is the length of the longest common prefix of a string and its suffix starting at i. The Z-algorithm computes all of them in O(n) by reusing a matching window, which gives pattern matching, periods and prefix-overlap answers.