Simple data structures Flashcards
Name 3 Simple Data Structures.
Arrays, Queues, Stacks
How does a stack work?
Adding: elements are pushed onto the top of the stack.
Retrieving: elements are popped from the top of the stack.
Elements are pushed and popped from the same end of the data structure.
LIFO
How does a queue work?
Adding: elements are enqueued from the tail
Retrieving: elements are dequeued from the head
Elements are enqueued and dequeued from opposite ends of the data structure.
FIFO
What methods are required for a Stack data structure?
Push: add an element to the stack
Pop: get the next element from the stack
What methods are required for a Queue data structure?
Enqueue: add an element to the queue
Dequeue: get the next element from the queue