On Time and Space Complexity

#datastructures #algorithmns #devstudy #BigONotation #timecomplexity #spacecomplexity

jarednielsen-big-o.png

Time Complexity: Time taken to run as a function of the length of the input

Not the most useful chart but that pastel-tone charcoal = yes

timecomplexity.png

Better chart but less aesthetic:

big-o-cheatsheet.png

From Fastest to Slowest:

O(1) time: One Operation

Examples

O(log n) time: Recursion?

Examples

O(n) time: Linear, i.e. Brute Force, Noob ones that I write bc my brain is stuck on iteration

Examples

O(n*log n) time: linear time complexity multiplied by log n

Examples

O(n^2) time: Quadratic.

Examples


Space Complexity: The space an algo needs to run

O(1) space: In-place

O(log n) space:

Examples

O(n) space: