CSCI 230 HW 5 Binary Tree traversals

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

Modify the author’s BinarySearchTree class (see General Resources on piazza).
1. Add 3 printTree methods (discussion in section 4.6 in text)
a. printTreePre displays tree contents in pre-order.
b. printTreePost displays tree contents in post-order.
c. printTreeLevel displays the tree contents in level-order. (Details of this one below)
printTreeLevel algorithm: Use a queue (a LinkedQueue from HW 4 will work fine) of Node
type,.
If the tree is not empty
Enqueue the tree’s root node
While the queue is not empty,
Dequeue a node;
Output the node’s data value
If the nodes’s left child is not empty, enqueue the node that is the left child
If the node’s right child is not empty, enqueue the node that is the right child
2. Write a main method that instantiates multiple binary search trees and displays the results of
all printTree algorithms on each tree. Your output should be clearly labeled. Include an
empty tree in your testing.
What to submit: Submit BinarySearchTree.java to OAKS no later than Friday, July 31,
10:00pm.