Write your answers to the following questions in a flat text file
hwkTrees.txt (not a Word document nor a Rich Text Format file):
- Binary Search Trees:
- Given an empty BST, insert the numbers 10, 5, 8, 7, 6, 9, 4, 3. Write the following traversals of the resulting tree:
- Pre-order Traversal
- In-order Traversal
- Post-order Traversal
Pre-order Traversal:
In-order Traversal:
Post-order Traversal:
-
Delete the following numbers from the BST: 7, 9 then 6. Write the pre-order traversal of the resulting tree.
- Using only BSTs, how can we make a copy of a BST and restore it so that it's in the exact same order as the original? (Hint: Think about tree traversal(s))
- How can we make a copy of a BST and restore it so that it's balanced?
- AVL Trees
- Given an empty AVL tree, insert the numbers 10, 5, 8, 7, 6, 9, 4, 3. For each insertion, indicate which (if any) AVL rotation was performed (see the example below). Record the pre-order traversal of the resulting tree.
Insert 10: No rotation
Insert 5: No rotation
Insert 8: Left Right
...
Pre-order Traversal:
- Delete the following numbers from the AVL tree: 7, 9 then 6. For each deletion, indicate which rotation was performed (if any). Record the pre-order traversal of the resulting tree.
- Splay Trees
- Given an empty Splay tree, insert the numbers 6, 4, 5, 3, 2. For each insertion, indicate which splaying was performed. Record the pre-order traversal of the resulting tree.
- Retrieve the following numbers from the Splay tree: 4, 3. For each retrieve, indicate which splaying was performed. Record the pre-order traversal of the resulting tree.
- For the following scenarios, choose the most appropriate tree structure to use among the following choices: binary tree, BST, AVL tree, Splay tree, and justify your choice:
- An emergency call center that needs to quickly retrieve arbitrary addresses
- A grocery store inventory system
- A sports or concert ticket sales system that stores events. It is very common for many of the queries (in a short amount of time) to be for the same event.
- Complete the following table for the minimum height required to store the specified number of Sequence objects:
Number of objects |
BST |
B-Tree (with 4 children) |
B-Tree (with 512 children) |
10 |
|
|
|
100 |
|
|
|
1000 |
|
|
|
10000 |
|
|
|
Submission
Submit your txt file at
https://3110.cs.mtsu.edu/. For further instructions, please see the
Miscellaneous page.
Rubric:
Points Question
------------ --------------------------------------------------------------
_____ / 2 1A BSTs: Insertion
_____ / 2 1B BSTs: Deletion
_____ / 2 1C BSTs: Restored
_____ / 2 1D BSTs: Balanced
_____ / 3 2A AVL Trees: (Rotations: 1 point; traversal: 2 points)
_____ / 2 2B AVL Trees: (Rotations: 1 point; traversal: 1 point)
_____ / 2 3A Splay Trees: (Rotations: 1 point; traversal: 1 point)
_____ / 2 3B Splay Trees: (Rotations: 1 point; traversal: 1 point)
_____ / 1.5 4 Scenarios
_____ / 3 5 Minimum Number Nodes
_____ / 21.5 Total