Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
14 Cards in this Set
- Front
- Back
What is a preorder tree traversal?
|
First traverse the root, then the left, then the right.
|
|
How do you implement an Least Recently Used algorithm using a circular linked list?
|
Assumption: data of each node contains a structure that contains a flag indicating whether the data has been used.
For each node in the list, if the data indicates that it has been used, set the flag to false and proceed to the next node. The first node that is reached that has data that indicates it hasn't been used is the LRU; if all data in the list has been used, eventually the iteration will come full circle and the first node in the list will be designated the LRU |
|
How do you implement a queue with a linked list?
|
enqueue inserts a node after the tail
dequeue removes the head |
|
How do you implement a stack with a linked list
|
push estabilishes a new node as the head
pop removes the current head |
|
First traverse the root, then the left, then the right.
|
What is a preorder tree traversal?
|
|
What is an inorder tree traversal
|
First traverse the left, then the root, then the right.
|
|
First traverse the left, then the root, then the right.
|
What is an inorder tree traversal
|
|
What is a postorder tree traversal
|
First traverse the left, then the right, then the root.
|
|
First traverse the left, then the right, then the root.
|
What is a postorder tree traversal
|
|
What is a level-order tree traversal
|
Traverse the root, and then visit nodes at each level from left to right (breadth-first exploration)
|
|
Traverse the root, and then visit nodes at each level from left to right (breadth-first exploration)
|
What is a level-order tree traversal
|
|
What's the definition of a balanced tree?
|
If all leaf nodes are at the same level, or if all leaf notes are in the last two levels and the second-to-last level is full
|
|
If all leaf nodes are at the same level, or if all leaf notes are in the last two levels and the second-to-last level is full
|
What's the definition of a balanced tree?
|
|
How do you flatten a tree into a linked list (breadth traversal)?
|
Pseudo code:
Node* current = root; while(current) { list.add(current->data); if(current->left) queue.enqueue(current-left); if(current-right) queue.enqueue(current-right); current = queue.dequeue(); } |