Big-O Flashcards
What is the time complexity of accessing an element in an array?
O(1)
What is the time complexity of searching in an unsorted array?
O(n)
What is the time complexity of inserting at the end of an array (amortized)?
O(1)
What is the time complexity of inserting at the beginning of an array?
O(n)
What is the time complexity of deleting an element from the middle of an array?
O(n)
What is the time complexity of accessing an element in a linked list?
O(n)
What is the time complexity of inserting at the head of a linked list?
O(1)
What is the time complexity of inserting at the tail of a singly linked list (without tail pointer)?
O(n)
What is the time complexity of deleting from the head of a linked list?
O(1)
What is the time complexity of searching in a linked list?
O(n)
What is the average time complexity of searching in a hash table?
O(1)
What is the worst-case time complexity of searching in a hash table?
O(n)
What is the average time complexity of inserting into a hash table?
O(1)
What is the worst-case time complexity of inserting into a hash table?
O(n)
What is the time complexity of searching in a binary search tree (average case)?
O(log n)
What is the time complexity of searching in a binary search tree (worst case)?
O(n)
What is the time complexity of searching in a balanced binary search tree?
O(log n)
What is the time complexity of inserting into a balanced binary search tree?
O(log n)
What is the time complexity of deleting from a balanced binary search tree?
O(log n)
What is the time complexity of heap insert (binary heap)?
O(log n)
What is the time complexity of heap delete (binary heap)?
O(log n)
What is the time complexity of heapify an entire array (building a heap)?
O(n)
What is the time complexity of searching in a heap?
O(n)
What is the time complexity of quicksort (average case)?
O(n log n)