Asymptotic Analysis (Easy/Medium) Flashcards
Two Number Sum
Time: O(n log(n))
Space: O(1)
Find Closest Value in BST
Time: O(log(n))
Space: O(1)
Depth First Search
Time: O(v + e)
Space: O(v)
Nth Fibonacci
Time: O(n)
Space: O(1)
Product Sum
Time: O(n)
Space: O(d)
Where d = greatest depth of the ‘special’ arrays
Binary Search
Time: O(log(n))
Space: O(1)
Find Three Largest Numbers
Time: O(n)
Space: O(1)
Bubble Sort
Time: O(n^2)
Space: O(1)
Insertion Sort
Time: O(n^2)
Space: O(1)
Palindrome Check
Time: O(n)
Space: O(1)
Caesar Cipher Encryptor
Time: O(n)
Space: O(n)
Branch Sums
Time: O(n)
Space: O(n)
Three Number Sum
Time: O(n^2)
Space: O(n)
Remember that the result is all ‘triplets’
Smallest Difference
Time: O(n log(n) + m log(m))
Space: O(1)
Move Element to End
Time: O(n)
Space: O(1)