Skip to main content

Big-O

Learn Big-O (Complexity, Programming Fundamentals) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

What is Big-O Notation? Big-O notation describes how the running time (or memory usage) of a program grows as the input size (usually called n ) grows. It answers one question: "If I double my input, roughly how much slower does my code get?" • Big-O describes the worst case / upper bound — the maximum amount of work the algorithm could possibly do for a given input size. • It ignores machine speed, JVM warm-up, constant factors — it only cares about the shape of growth as n gets large. • It is written as O(f(n)) , e.g. O(n) , O(n^2) , O(log n) . Think of Big-O as a "speed label" on an...

More lessons in Complexity