2.3.2 - Algorithms for Main Data Structures Flashcards
What is a stack?
A stack is a first-in, last-out data structure.
How do you check the size of a stack?
Size()
How do you check if a stack is empty?
isEmpty()
How do you return the top element of a stack but not remove it?
Peek()
How do you add an item onto a stack?
Push(element)
How do you return and remove the top element of a stack?
Pop()
What is a queue?
A queue is a first-in, first-out data structure.
How do you check the size of a queue?
Size()
How do you check if the queue is empty?
IsEmpty()
How do you return the front element but not remove it from a queue?
Peek()
How do you add an element to a queue?
Enqueue(element)
How do you remove and return the front element from a queue?
Dequeue()
How is a tree formed?
Trees are formed from nodes and edges.
What are the two types of tree-traversal?
Depth first (post-order) traversal and breadth first traversal.
How does depth first traversal work?
It works in the same way as a post-order traversal.
Draw around the graph and mark the nodes when the drawing goes around on the right of the node.