ADT Stacks and Queues (Module 3) Flashcards
What is a single expected way to traverse elements in a data structure?
linear
What is a structure that can hold elements and give us a way to get them back?
worklists
What is a container where elements are added and removed only at the end?
stack
Stacks are characterized by which two operations?
push() and pop()
Which operation adds a new element to the stack?
push()
Which operation removes an element from the stack?
pop()
The insertion and retrieval of elements in a stack follows the “___ In, _____ Out” discipline
Last In, First Out
What is an operator that returns a reference to an element at the top of the stack but doesn’t remove it from the stack?
peek()
Which operator returns “True” if the stack is empty, and “False” in other cases?
isEmpty()
What occurs when attempting to insert a new element into a stack that’s already reached its maximum size limit?
stack overflow
What occurs when attempting to delete or retrieve an element from a stack that’s empty
stack underflow
What is thee asymptotic complexity for pop() and push()?
O(1)
What is a container where the elements are added at one end and removed at another end?
Queue
Queues are characterized by which two operators?
enqueue() and dequeue()
Which operator inserts a new element into the queue?
enqueue()
Which operator removes the first element of the queue?
dequeue()
Queues follow the “_____ In, ______ Out” discipline.
First In, First Out (FIFO)
Which copy creates a new object but doesn’t create copies of nested objects?
shadow copy
Which copy creates a completely independent copy of the original object, including copies of all the nested objects?
deep copy