Trees Flashcards
A queue operates under a WHAT policy?
FIFO - First In, First Out
You may only read or remove the item at the WHAT of a queue?
Front/Head
You may only add an item at the WHAT of a queue?
Back/Tail
List the methods of Java’s Queue interface.
add(E item), element(), offer(E e), peek(), poll(), remove()
The element() method of Java’s Queue interface removes the head of the queue: true or false?
False; it retrieves, but does NOT remove the head of the queue.
You want to insert an item into a queue. Which one of Java’s Queue interface methods do you use?
Either add(E e) or offer(E e). The only difference is in the return type.
You want to retrieve, but NOT remove, the first element in a queue. Which one of Java’s Queue interface methods do you use?
Either E element() or E peek(). The only difference is in the return type.
You want to retrieve AND remove the first element in a queue. Which one of Java’s Queue interface methods do you use?
Either E remove() or E poll(). The only difference is in the return type.
A Deque allows insertion and deletion at both the head and tail: true or false?
True. That’s why it’s called a DOUBLY ENDED Queue.
Number of edges in a tree = ?
Number of vertices - 1.
Define “minimally connected”.
The tree will become disconnected if any edge is removed.
Define “maximally acyclic”.
If an edge is added, the tree will contain a cycle.
The child of a child of a given node is referred to as?
A “descendant”.
A node that has no children is called?
A “leaf”.
What is the height of a node?
The distance of a node from its deepest descendant.