Data Structures time complexity
Big Omega
Best case, lower bound runtime of a method
Queue (insert/enqueue method)
O(1): Constant time If there is a linked list implementation containing both a head and a tail pointer O(n): Linear time If there is a linked list implementation containing only a head pointer then you must iterate through the list until you find the last value
Queue (delete/dequeue method)
O(1): Constant time Since queue is a Last-In-First-Out data structure, the first element to be deleted will be at the top of the queue
Stack (delete method)
O(1): Constant time Since stack is First-In-First-Out, then deletion from the stack is constant time as it is just taken from the top.
Stack (insert method)
O(1): Constant time Since stack is First-In-First-Out, then insertion into the stack is constant time as it is just added to the top.
Singly Linked List (insert method)
O(1): constant time Insert at beginning or end of the list provided there is both a head and tail pointer O(n): linear time Insert at a specific place in the list. This is the runtime of the find method.
Doubly linked list (delete method)
O(1): constant time When provided a pointer to the node to be deleted, the runtime is constant. O(n): linear time When not provided a pointer to the node to be deleted
AVL Tree (delete method)
O(log(n)): Logarithmic time AVL tree guarantees logarithmic runtime for all methods.
AVL Tree (find method)
O(log(n)): Logarithmic time AVL tree guarantees logarithmic runtime for all methods.
AVL Tree (insert method)
O(log(n)): Logarithmic time AVL tree guarantees logarithmic runtime for all methods.
Binary Heap (delete method)
O(log(n)): Logarithmic time Worst case: once the old root is deleted and replaced with the last inserted node, the new root must be swapped with its child until it reached the bottom of the heap
Binary Heap (insert method)
O(log(n)): logarithmic time Must percolate all the way to the top of the heap in the worst case scenario.
Hash Table (delete method)
O(n): Linear time If you are employing collision method of separate chaining and all of the values hash to the same place, then iterating through the linked list is linear time.
Hash Table (insert method)
O(n): Linear time If you are employing collision method of separate chaining and all of the values hash to the same place, then iterating through the linked list is linear time.
Hash Table (find method)
O(n): Linear time If you are employing collision method of separate chaining and all of the values hash to the same place, then iterating through the linked list to find the value you are looking for is linear time.
Singly linked list (delete method)
O(n): Linear time Must first find the node to be deleted, and then must delete it. Even if a pointer to the node to be deleted is provided, you must get a previous node pointer by iterating through the list
Singly linked list (find method)
O(n): Linear time Must iterate through the entire list to find the node you are looking for.
Binary Heap (find method)
O(n): Linear time When looking for a random node in the heap, you may have to iterate through every single node in the heap as the ordering property is not helpful in finding things O(1): Constant time When looking for the min value in a min-heap or the max value in a max-heap
Binary Search Tree (delete method)
O(n): Linear time Worst case scenario is that you must iterate through all of the nodes in the BST before finding the one to be deleted.
Binary Search Tree (find method)
O(n): Linear time Worst case scenario is that you must iterate through all of the nodes in the BST before finding the one you are looking for.
Doubly linked list (find method)
O(n): linear time Entire list must be traversed until node is found.
Doubly linked list (insert method)
O(n): linear time Entire list must be traversed until node is found.
Binary Search Tree (insert method)
O(n): linear time Worst case scenario is that the BST is entirely unbalanced (and inserts elements from an already sorted list).
Big Theta
Tight bound on the runtime of a method
Big-Oh
Worst case scenario runtime, the upper bound to the runtime of a method