Algorithms_ Asymptotic Notation Cheatsheet _ Codecademy
Algorithms_ Asymptotic Notation Cheatsheet _ Codecademy
Asymptotic Notation
Analyzing Runtime
The big-O runtime for locating the maximum value in a list # O(N) runtime
of size N is O(N). This is because the entire list of N
def find_max(linked_list):
members has to be traversed.
current = linked_list.get_head_node()
maximum = current.get_value()
while current.get_next_node():
current = current.get_next_node()
val = current.get_value()
if val > maximum:
maximum = val
return maximum
Big-Θ Notation
Adding Runtimes
When an algorithm consists of many parts, we describe its An algorithm with three parts has running
runtime based on the slowest part of the program.
times of Θ(2N) + Θ(log N) + Θ(1). We only
care about the slowest part, so we would
quantify the runtime to be Θ(N). We would
also drop the coefficient of 2 since when
N gets really large, the multiplier 2 will
have a small effect.
Big-Ω Notation
Print Share