Big-O Complexity Flashcards
1
Q
what does O(1) mean
A
O(1) means that the algorithm will always execute in the same time no matter size of input data set.
2
Q
Put these Big-O expression in order of complexity:
O(1) O(2n) O(log n) O(n2) O(N3) O(n) O(n log n)
A
O(1) O(log n) O(n) O(n log n) O(n2) O(N3) O(2n)
3
Q
Work out this function with Big-O complexity:
2n2 + 3N
A
O(n2)
then another three loops not nested: 2N² + 3N
remove everything except the highest term: 2N²
remove all constants: N²
other words two loops with another one nested inside, then another three loops not nested is O(N²)