Creates a new tree symmetric to the current instance

Assignment Help C/C++ Programming
Reference no: EM131283842

In this programming assignment you are asked to implement five new methods of the Binary Tree ADT developed in class.

Use recursion when it is possible. The new methods are: SumLeaves, NumberOfOdd, MultipleOf, Clone, and DeleteSubtree.

The specifications of these methods are provided below:

 int SumLeftLeaves( )
- Function: returns the sum of all the left leaves' info. - Precondition: Tree has been initialized.
- Postcondition: Function value = sum value of all left leaves' info.

int NumberOfOdd()
- Function: Returns the number of odd elements that exist in the tree.
- Precondition: Tree has been initialized
- Postcondition: Function value = 0 if no odd element exist in the tree, else it returns the number of odd elements existing in the tree.

 bool MultipleOf(int item)
- Function: Checks if the elements stored in the tree are multiple of item.
- Precondition: Tree and Item have been initialized
- Postcondition: Function value = TRUE if all items of the tree are multiple of item; FALS E otherwise.

 BinaryTree SymmetricClone ()
- Function: creates a new tree symmetric to the current instance.
- Precondition: Tree has been initialized - Postcondition: Function value = a new tree is created that
contains elements of the tree with left subtree becoming a right subtree and vice-versa.

 void DeleteSubtree(int el)
- Function: deletes the subtree having el as a root.
- Precondition: tree and el have been initialized - Postcondition: Function value = all nodes belonging to the
subtree with root el are deleted from the tree

First, double check that the program Assig4.cpp creates correctly the below three trees.
BinaryTree tree1, tree2, tree3, tree4;

tree2.SumLeftLeaves(); returns 10+15=25 tree3.SumLeftLeaves(); returns 60=60
tree1.numberOfOdd(); returns 6 tree2.numberOfOdd(); returns 3 tree3.numberOfOdd(); returns 0
tree1.multipleOf(3); returns FALSE tree2.multipleOf(5); returns TRUE tree3.multipleOf(10); returns TRUE
tree4 = tree2.SymmetricClone(); tree4.Print(InOrder); displays 10, 20, 25, 15, 5, 30, 60, 10,
tree2.deleteSubTree(20); tree2.Print(InOrder); displays 10, 5, 60, 10, 30,

The givin code::

#include <iostream>
#include <iomanip>

using namespace std;

#include "BinaryTree.h"

int main(int argc, char* argv[]) {
BinaryTree tree1, tree2, tree3, tree4;
BTNode *left, *right, *node, *root;

//Creating the special tree1 as shown in the figure provided in the assignment
tree1.insert(10);
root = tree1.Root();
left = new BTNode(7);
node = new BTNode(4, 0, left);
left->parent = node;
right = new BTNode(7);
node = new BTNode(5, root, node, right);
node->left->parent = node;
right->parent = node;
root->left = node;
left = new BTNode(7);
right = new BTNode(25);
node = new BTNode(7, root, left, right);
right->parent = node;
root->right = node;

//Creating the special tree2 as shown in the figure provided in the assignment
tree2.insert(10);
root = tree2.Root();
left = new BTNode(10);
node = new BTNode(60, 0, left);
left->parent = node;
right = new BTNode(30);
node = new BTNode(5, root, node, right);
node->left->parent = node;
right->parent = node;
root->left = node;
left = new BTNode(15);
right = new BTNode(25);
node = new BTNode(20, root, left, right);
right->parent = node;
root->right = node;

//Creating the special tree3 as shown in the figure provided in the assignment
tree3.insert(10);
root = tree3.Root();
left = new BTNode(60);
node = new BTNode(40, 0, left);
left->parent = node;
node = new BTNode(20, root, node);
node->left->parent = node;
root->left = node;
right = new BTNode(50);
node = new BTNode(30, root, 0, right);
right->parent = node;
root->right = node;

cout<<"Tree1 : "; tree1.Print(InOrder);
cout<<"Tree2 : "; tree2.Print(InOrder);
cout<<"Tree3 : "; tree3.Print(InOrder);

system("PAUSE");

return 0;
}

******************************************************************************************************

Write the program using C++ visual studio 2013 + versions

I need the full file the header and the cpp files and any other files used make sure that i can run it in any project.

Verified Expert

In this programming assignment we implement five new methods of the Binary Tree ADT developed in class. The new methods are: SumLeaves, NumberOfOdd, MultipleOf, Clone, and DeleteSubtree.

Reference no: EM131283842

Questions Cloud

What about environmentalists or union leaders : Who should and should not serve on a board of directors? What about environmentalists or union leaders? Explain the relationship between corporate governance and social responsibility?
Provide an overview of germanys economy : Provide an overview of Germany's economy. Describe and explain performances trends of the economy based on graphs given, including discussion on the unusual year.
Explain how multiple systems interact to impact individuals : Explain how multiple systems interact to impact individuals. Explain how you, as a social worker, might apply a systems perspective to your work with Lester Johnson. Finally, explain how you might apply a systems perspective to social work practice..
Review the discussion of diffusion theory : Review the discussion of diffusion theory. How might an understanding of the characteristics of innovations help marketers succeed in emerging markets?
Creates a new tree symmetric to the current instance : creates a new tree symmetric to the current instance - Precondition: Tree has been initialized - Postcondition: Function value = a new tree is created that
Functional silos are not appropriate for today organization : Why do you think functional silos are not appropriate for today's organization? Discuss your answer from organizational and technical perspectives. Use terminology from the chapter in the discussion.
Various importance of curriculum theories : Write on the various importance of curriculum theories in vocational and technical education.
What trade-offs are involved in deciding to have a single : What trade-offs are involved in deciding to have a single large, centrally located facility instead of several smaller, and dispersed facilities? Who needs to be involved in this decision?
Assess estee lauders strategy for china : How do women's preferences for cosmetics and beauty care vary from country to country?- Assess Estée Lauder's strategy for China.

Reviews

inf1283842

11/21/2016 4:28:46 AM

kindly make sure that your expert does not live currently in Abu Dhabi more explanation in the file 19513533_1the view.png

len1283842

11/21/2016 3:37:14 AM

Need to complete the full code with the hash for explaining each part in the code (full notation)implement five new methods of the Binary Tree ADT developed in class. Use recursion when it is possible. The new methods are: SumLeaves, NumberOfOdd, MultipleOf, Clone, and DeleteSubtree.

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd