Computer Science Flashcards
What is a Stack?
is a list-type abstract data structure that limits interaction to one end of the list.
What does the acronym LIFO mean?
Last In First Out
What methods are available on a Stack data structure?
push(value) - adds value to top of stack
pop() - removes the top value from the stack and returns it
peek() - returns the top value of the stack without removing it
What must you do to access the value at an arbitrary point in a stack (not just the top)?
pop from the stack repeatedly until you find the point you need
What is a queue?
a list-type abstract data structure that limits interaction with its contents
What does the acronym FIFO mean?
first in first out
What methods are available on a Queue data structure?
enqueue(value) - adds a value to the “back” of the queue.
dequeue() - removes the “front” value from the queue and returns it.
peek()- returns the front value without removing it
What must you do to access the value at an arbitrary point in a queue (not just the front)?
dequeue from the front value until you get to the arbitrary point in the queue
What is a linked-list data structure?
A linked list is a concrete data structure consisting of a bunch of value-containing nodes strung together into a single sequential list
How are linked-lists different from an array?
linked-lists are sequential access like a queue, not random access like an array.
How would you access an arbitrary node in a linked list? (not just the head)
In order to go to a specific place in the list, you have to start at the beginning, then jump from node to node until you get to the specific node.
How is a linked-list different from a queue?
a linked-list doesn’t have to be mutated to see the next value in the linked-list