Sale!

CSC230 Lab 10

$25.00

Category:
5/5 - (2 votes)

CSC230 Lab 10

Goal: This lab will teach you about tree operations.
Part I
——————
Download the files from Canvas. There are three files in the contents. They are
treeNode.h, tree.h, and test.cpp.
In this lab, do NOT modify anything in treeNode.h and test.cpp. Your work is to
implement the methods in tree.h file. In the tree.h file, please implement the following
methods:
• treeBSearch(V x, TreeNode<V>* t)
• isLeaf(TreeNode<V>* t)
• height(TreeNode<V>* t)
• nNodes()
• insert(V x)
After finishing the implementation, type the following command to compile the code.
g++ test.cpp
where file test.cpp tests the implementations of the methods. The execution result of
test.cpp is:
jikaili$ ./a.out
1
0
8
The Tree Looks Like:
9
/
8
\
7
/
6
/
5
\
4
/
3
\
2
The tree is rooted at node 5.
Your implementation must have the exactly same result.
Requirements and Hints:
• The tree should be sorted, the values of left subtree are smaller than the root; the
values of the right subtree are larger than the root
• When you insert a node, pretend that you are searching the value, insert the node
to the place where it falls off the tree
Wrap up
————————
Submit .cpp files to Canvas.

PlaceholderCSC230 Lab 10
$25.00
Open chat
Need help?
Hello
Can we help?