Study this topic

Asymptotic Notation

The exact running time of a program depends on the machine, the compiler and the input. To compare algorithms rather than programs, we describe how the running time grows as the input size n grows, ignoring constant factors and small inputs.

Short notes8 min read

Time and Space Complexity Analysis

Asymptotic notation says how to compare growth rates. This note shows how to obtain the function to compare: how to count the work done by loops, nested loops and recursive calls, and how much memory a program needs beyond its input.

Short notes8 min read

Solving Recurrences and the Master Theorem

The running time of a recursive algorithm is naturally described by a recurrence: an equation that gives T(n) in terms of T on smaller inputs. Merge sort splits an array into two halves, sorts each and merges in linear time, so T(n) = 2T(n/2) + Θ(n).

Short notes8 min read