Time and space complexity of common data structure operations and algorithms, plus amortized analysis and recurrence solutions.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What is the time complexity of accessing an element in an array by index?
Show answer
O(1) constant time
- What is the time complexity of searching for a value in an unsorted array?
Show answer
O(n) linear time
- What is the time complexity of inserting an element into an array?
Show answer
O(n) linear time
- What is the time complexity of deleting an element from an array?
Show answer
O(n) linear time
- What is the time complexity of accessing an element by position in a singly linked list?
Show answer
O(n) linear time
- What is the time complexity of inserting at the head of a singly linked list?
Show answer
O(1) constant time
- What is the time complexity of deleting the head node from a singly linked list?
Show answer
O(1) constant time
- What is the average-case time complexity of searching in a hash table?
Show answer
O(1) constant time
- What is the worst-case time complexity of searching in a hash table?
Show answer
O(n) linear time
- What is the average-case time complexity of search, insert, and delete in a binary search tree?
Show answer
O(log n) logarithmic time
- What is the worst-case time complexity of operations in an unbalanced binary search tree?
Show answer
O(n) linear time
- What is the time complexity of all operations in an AVL tree or Red-Black tree?
Show answer
O(log n) logarithmic time
- What is the time complexity of inserting an element into a binary heap?
Show answer
O(log n) logarithmic time
- What is the time complexity of removing the minimum element from a min-heap?
Show answer
O(log n) logarithmic time
- What is the time complexity of peeking at the minimum element in a min-heap?
Show answer
O(1) constant time