Skip to content

Latest commit

 

History

History
35 lines (29 loc) · 1.31 KB

timeComplexity.md

File metadata and controls

35 lines (29 loc) · 1.31 KB

Time Complexity

Since these questions are all multiple choice I'm going to write down the write answers here

Basic Primer

Name Answer
LOOP_CMPL O(N + M) time, O(1) space
NESTED_CMPL O(N * N) time, O(1) space
NESTED_CMPL2 O(N*N)
CHOOSE4 X will always be a better choice for large inputs

Math

Name Answer
WHILE_CMPL O(log N)
NESTED_CMPL3 O(N)

Compare Functions

Name Answer
CHOOSE1 n^3 / (sqrt(n))
CHOOSE2 f3, f2, f4, f1
CHOOSE3 c

Function calling itself

Name Answer
REC_CMPL1 O(N)
REC_CMPL2 O(2^(R + C))

Amortized

Name Answer
AMORTIZED1 O(N)