Question: IN C++ CODING ----- BTREE SKELETON IS PROVIDED. BTREE SKELETON---- In this assignment, you are given several classes in the cpp file BTree.cpp. Your task

IN C++ CODING ----- BTREE SKELETON IS PROVIDED.

 IN C++ CODING ----- BTREE SKELETON IS PROVIDED. BTREE SKELETON---- In

this assignment, you are given several classes in the cpp file "BTree.cpp".

BTREE SKELETON----

Your task is to complete the implementation of the classes specified as

below. You need to submit a single cpp file that contains everything

In this assignment, you are given several classes in the cpp file "BTree.cpp". Your task is to complete the implementation of the classes specified as below. You need to submit a single cpp file that contains everything about your source code. It must be compilable and executable. Do not submit things irrelevant (such as .exe) 1 Your Task You are given a class "TNode" that contains one integer value, and three pointers - one to the parent, one to the left child, and one to the right child. You need to complete the class "BTree" and two other functions specified in the cpp file Task 1: Write a function isValidBT that given inputs as a binary tree in the array form, and outputs whether the array forms a correct binary tree. The inputs contain a pointer p to an array, and an integer n denoting the number of slots used in the array representation. Here the array has size n, and we use p[0 to store the empty symbol for the binary tree as discussed in the class. For this representation, the tree has size n - 1 Task 2: Implement the constructors (default and copy) of BTree, and the destructor. You need to make sure that the copy constructor makes a separate copy of the list In addition to the normal copy constructor, here we ask you to implement a special "copy constructor" that takes input a binary tree of the array form. The inputs have the same format as Task 1, and you need to copy the binary tree, and convert the array form/to the pointer-based construction Task 3: Implement the function convertpos that takes input an integer position, and returns the TNode pointer that points to the position-th node in the tree. We discussed about how to do this in the class. Task 4: Implement the add2left, add2right functions. The functionalities are just as the names Here you need to consider how to handle different input of positions, i.e. places that you want to add the node/tree to. You need to consider whether the position is available to add a new node. Task 5: Write the removeleaf function. You need to first check whether the input is a leaf or not If that is a leaf, then remove it. Otherwise do nothing

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!