Fill This Form To Receive Instant Help
Homework answers / question archive / Implement a Binary tree
node has at most two children. Each node is an object containing a string.
2.Your binary tree class has to support the following functions:
(a) size(): Returns the number of nodes in the tree.
(b) addLeftChild(node parent,node Child): Adds a left child to the par- ent node
(c) addRightChild(node parent,node Child): Adds a right child to the parent node
(d) Ischild(): returns true if the node is the child of a given node and false otherwise.
(e) root(): which will return the Root.
(f) Height(): which will return the height of the tree;
3.insert the following into the tree. The root is a node containing the string:"Creature". The left child of root is a node containing the string:"Human". The Right Child of root is a node containing the string:"Animal". The left child of the node containing "Human" is a node containing the string:"alive"
and the right child of the node containing "Human" is a node containing the string:" dead". The right child of the node containing "Animal" is anode containing the string:"wild". And Animal does not have a left child.
4.implement the pre-order and post-order traversal algorithms discussed in the class to print the content of each of the nodes.