Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need to write the following functions in table.cpp, and add function prototypes for them to table.h and invoke the functions in main.cpp. * int sumOfNodes(node

Need to write the following functions in table.cpp, and add function prototypes for them to table.h and invoke the functions in main.cpp.

* int sumOfNodes(node * root)

Recursively calculate the sum of all the nodes in the tree.

* void copyLeaf(node * src, node *& dest)

Recursively copy all the leaves from the source tree to the destination tree. The destination tree must be a binary search tree.

--------------------------------------------------------------------------------------------

main.cpp

#include "table.h"

#include

using namespace std;

int main() { node * root = NULL; build(root); display(root);

/* PLACE YOUR FUNCTION CALL HERE */

display(root); destroy(root); return 0; }

-----------------------------------------------------------------

table.h

#ifndef TABLE_H #define TABLE_H //table.h #include #include #include using namespace std;

struct node { int data; node * left; node * right;; };

void build(node * & root); //supplied void display(node * root); //supplied void destroy(node * & root); //supplied

/* ************** PLACE YOUR PROTOTYPE HERE ***************** */

#endif

------------------------------------------------------------

table.cpp

#include "table.h"

//Please put the impelementation of the required functions here

----------------------------------------------------------------------------------------

Please make sure the functions are done recursively, and are done in C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

Students also viewed these Databases questions

Question

What are business ethics? How are ethics relevant to research?

Answered: 1 week ago

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago