Data Structures Flashcards
What is a stack?
A stack is a set with a LIFO policy.
The element deleted from the set is the one most recently inserted.
What is a queue
A queue is a set with a FIFO policy.
The element deleted from the set is the one that has been in the set for the longest time.
What is a linked list
A linked list is a data structure in which the object are arranged in a linear order.
Unlike an array, in which the linear order is determined by the array indices, the order in a linked list is determined by a pointer in each object.
Complexity: Copy list
Average case: O(n)
Amortized worst case: O(n)
Complexity: Append to list
Average case: O(1)
Amortized worst case: O(1)
Complexity: Pop last from list
Average case: O(1)
Amortized worst case: O(1)
Complexity: Pop intermediate from list
Average case: O(n)
Amortized worst case: O(n)
Complexity: Insert into list
Average case: O(n)
Amortized worst case: O(n)
Complexity: Get item from list
Average case: O(1)
Amortized worst case: O(1)
Complexity: Set item in list
Average case: O(1)
Amortized worst case: O(1)
Complexity: Delete item from list
Average case: O(n)
Amortized worst case: O(n)
Complexity: List iteration
Average case: O(n)
Amortized worst case: O(n)
Complexity: Get slice from list
Average case: O(k)
Amortized worst case: O(k)
k = Size of slice
Complexity: Delete slice from list
Average case: O(n)
Amortized worst case: O(n)
Complexity: Set slice in list
Average case: O(k+n)
Amortized worst case: O(k+n)
k = size of slize
Complexity: Extend list
Average case: O(k)
Amortized worst case: O(k)
k = size of 2nd list
Complexity: Sort list
Average case: O(n log n)
Amortized worst case: O(n log n)
Complexity: Multiply list
Average case: O(n * k)
Amortized worst case: O(n * k)
Complexity: x in list
Average case: O(n)
Complexity: min() / max() of list
Average case: O(n)
Complexity: Get length of list
Average case: O(1)
Amortized worst case: O(1)
Complexity: Copy dequeue
Average case: O(n)
Amortized worst case: O(n)
Complexity: Append to dequeue
Average case: O(1)
Amortized worst case: O(1)
Complexity: Append left to dequeue
Average case: O(1)
Amortized worst case: O(1)
Complexity: Pop from dequeue
Average case: O(1)
Amortized worst case: O(1)
Complexity: Pop left from dequeue
Average case: O(1)
Amortized worst case: O(1)