Big-O Notations Flashcards
1
Q
For Arrays?
A
- traverse all spots = O(N)
- search for an item = O(N) or O(Log2N)
- removed any item location unknown = O(N)
- get any item location unknown = O(1)
- add item at the end = O(1)
- add item at the front = O(N)
2
Q
For Single Linked Lists?
A
- traverse all nodes = O(N)
- search for an item = O(N)
- remove any item location unknown = O(N)
- get any item location unknown = O(N)
- add item at the end O(N)
- add item at the front = O(1)
3
Q
For Double Linked List?
A
- traverse all nodes = O(N)
- search for an item = O(N)
- remove any item location unknown = O(N)
- get any item location unknown = O(N)
- add item at the end = O(1)
- add item at the front = O(1)
4
Q
For Binary Search Tree
A
- traverse all nodes = O(N)
- search for an item = O(log2N)
- remove any item location unknown = O(log2N)
- get any item location unknown = O(log2N)
- add item at the end = O(log2N)
- add item at the front = O(1)
5
Q
For ArrayList?
A
- traverse all spots = O(N)
- search for an item = O(N) or O(log2N)
- remove any item location unknown = O(N)
- get any item location unknown = O(1)
- add item at the end = O(1)
- add item at the front = O(N)
6
Q
For LinkedList?
A
- traverse all spots = O(N)
- search for an item = O(N)
- remove any item location unknown = O(N)
- get any item location unknown = O(N)
- add item at the end = O(1)
- add item at the front = O(1)
7
Q
For TreeSets?
A
- add() = O(log2N)
- get() = O(log2N)
- containsKey() = O(log2N)
8
Q
For HashSets?
A
- add() = O(1)
- get() = O(1)
- containsKey() = O(1)
9
Q
For TreeMap?
A
- put() = O(log2N)
- get() = O(log2N)
- containsKey() = O(log2N)
10
Q
For Hash Map?
A
- put() = O(1)
- get() = O(1)
- containsKey() = O(1)