Question: PART 1 GENERAL TREES Helper function to be used in the findHeight() function In this part you will be implementing a general tree data structure

 PART 1 GENERAL TREES Helper function to be used in the

PART 1 GENERAL TREES Helper function to be used in the findHeight() function In this part you will be implementing a general tree data structure where each node of a tree can have any number of children nodes. Refer to tree.hpp which provides all the required definitions. Write your implementation in tree.cpp using the boiler code. void delete Tree(shared_ptr> currNode) Delete the entire tree. . Member Functions: Write implementation for the following methods as described here: bool deleteLeaf(T key) Delete node with given key if and only if it is a leaf node i.e. have no child. Doesn't delete the root node even if it is the only node in the tree. Returns true on success, false on failure. Tree(shared_ptr> root) Constructor shared_ptr> deleteLeafHelper (shared_ptr> curr Node, T key) Helper function to delete the leaf node. shared_ptr> findKey(T key) Finds the node with the given key and returns a pointer to that node. NULL is returned if the key doesn't exist. shared_ptr> findKeyHelper (shared_ptr> currNode, I key) Helper function to be used in findkey (T key) function bool insertChild(shared_ptr> newNode, T key) Inserts the given node as the child of the given key. Returns true if insertion is successful and false if key doesn't exist. Insertion should also fail if another node with the same key as the new node already exists i.e. duplicates are not allowed. If the node at the given key already has children, the new node must be added to the tail of the children of that node. vector>> getAllChildren(T key) Returns all the children of the node with the given key. Should return an empty vector in case the node has no child or key doesn't exist. int findHeight() Returns the height of the tree

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!