time complexity Flashcards
1
Q
what is time complexity
A
time complexity of an algorithm describes how time taken to execute it grows with the size of the input data
- time complexity does not indicate actually performance
2
Q
linear search, insert remove
A
search: O(1)
insert: O(n)
remove: O(n)
3
Q
linked list search, insert remove
A
search: O(n)
insert: O(1)
remove: O(1)
4
Q
binary search, insert remove
A
search: O(log(n)); worse case (O(n))
insert: O(log(n))
remove (leaf node/ one child node): O(1)
remove (two-child node): O(log(n))