1 answer

C++ Write a public member function incrementNodes for a BinaryTree class that will add 1 to...

Question:

C++

Write a public member function incrementNodes for a BinaryTree class that will add 1 to each item in the binary tree. If this function calls any other function, you must write the code for that function as well. Note that the class BinaryTree has a private member variable root which is a Node pointer.


Answers

#include <iostream>  using namespace std;  struct Node {     int data;     Node *left;     Node *right; };  class BinaryTree { private:    Node *root;    void incrementNodes(Node *temp); public:    void incrementNodes(); };  // Below is the code that you need void BinaryTree::incrementNodes() {     incrementNodes(root); }  void BinaryTree::incrementNodes(Node *temp) {     if(temp != NULL) {         temp->data += 1;    // increment data in node         incrementNodes(temp->left); // recursive call to left subtree         incrementNodes(temp->right);    // recursive call to right subtree     } } // Above is the code that you need  int main() {    return 0; }

Hey\;let\;me\;know\;if\;you\;need\;me\;to\;change\;anything

Please\;upvote\;this\;answer..

.

Similar Solved Questions

1 answer
+BACK NEXT FULL SCREEN PRINTER VERSION MESSAGE MY INSTRUCTOR Interactive LearningWare 27.2 reviews the concepts that...
+BACK NEXT FULL SCREEN PRINTER VERSION MESSAGE MY INSTRUCTOR Interactive LearningWare 27.2 reviews the concepts that are important in this problem. A uniform layer of water (n = 1.33) lies on a glass plate (n = 1.52). Light shines perpendicularly on the layer. Because of constructive interference, t...
1 answer
When looking at a karyotype, for example to diagnose trisomy 21 in a fetus, is it...
When looking at a karyotype, for example to diagnose trisomy 21 in a fetus, is it possible to use that analysis also to tell if the fetus has inherited a cystic fibrosis allele from a carrier mother?...
1 answer
Give notes to what each look like and description in text form Lab#1 –Learning Some Basics...
give notes to what each look like and description in text form Lab#1 –Learning Some Basics applied Skills We have completed our initial install of Ubuntu and begun to feel our way around our new system. The following assignment will help you familiarize yourself with your new environment. Plea...
1 answer
The formal charge is the "charge" an element would have in a molecule or ion if...
The formal charge is the "charge" an element would have in a molecule or ion if all of the bonding electrons were shared equally between atoms We can draw three inequivalent Lewis structures for the selenite ion , Se032-. The concepts of formal charge and electronegativity can help us choose...
1 answer
C6h6+3h6 --> c6h12 equilibrium equation
c6h6+3h6 --> c6h12 equilibrium equation...
1 answer
Question 3 (10 points) Electo-matic manufactures injection molded plastic frames for use in motor controllers. The...
Question 3 (10 points) Electo-matic manufactures injection molded plastic frames for use in motor controllers. The annual demand for these injection molded plastic frames is 185,000 units. Electo-matic can produce 1,300 injection molded plastic frames per hour and the company works an 8 hour day for...
1 answer
Whole farm planning can be assessed using linear programming in order to determine optimum combinations of outputs to produce in order to maximize gross margin or profit. True False
Whole farm planning can be assessed using linear programming in order to determine optimum combinations of outputs to produce in order to maximize gross margin or profit. True False...
1 answer
Required information The following information applies to the questions displayed below. Jeremy earned $100,500 in salary...
Required information The following information applies to the questions displayed below. Jeremy earned $100,500 in salary and $6.500 in interest income during the year, Jeremy's employer withheld $11,000 of federal income taxes from Jeremy's paychecks during the year, Jeremy has one qualifyi...
1 answer
(c) Under a large sample, given a, a hypothesis test for the mean, Ho : H...
(c) Under a large sample, given a, a hypothesis test for the mean, Ho : H = Ho vs. He: > Mo, fails to reject the null if & -10 <za Show that this is equivalent to not rejecting H, if Ho is greater than the lower confidence bound of a 100(1 - a)% one-sided confidence interval....
1 answer
SAS BASE PROGRAMMING Q newvar=substr('The ocean stirs the heart, inspires the imagination., 8, 10); Select one:...
SAS BASE PROGRAMMING Q newvar=substr('The ocean stirs the heart, inspires the imagination., 8, 10); Select one: a. None of the other choices b. NEWVAR is equal to 'an stirs t' C. NEWVAR is equal to 'n stirs th' d. NEWVAR is equal to 'an' In which step can variable attrib...
1 answer
Identify the Bronsted-Lowry base in the reaction: PO43 + H2O - HPO42 + OH PO, 0...
Identify the Bronsted-Lowry base in the reaction: PO43 + H2O - HPO42 + OH PO, 0 он 0 HPO? 0 Hz0...
1 answer
2x 0<x<1 Let X be a continuous random variable with probability density function f(x)= To else...
2x 0<x<1 Let X be a continuous random variable with probability density function f(x)= To else The cumulative distribution function is F(x). Find EX....
1 answer
Determine the reactions at the beam supports for the given loading if F1 is 360 Ib/ft....
Determine the reactions at the beam supports for the given loading if F1 is 360 Ib/ft. (Round the final answers to the nearest whole number.) F1 150 lb/ft 4 ft The reaction A at the beam support is The moment MA at the beam support is 3 ft lb lb-ft...
1 answer
Retallick Ltd sells boats and provides mooring services to its customers. They usually sell the boats...
Retallick Ltd sells boats and provides mooring services to its customers. They usually sell the boats for $30,000 each and mooring services for $5,000 per year paid annually in advance. Furthermore they consider the boats and mooring services to be distinct and account for them as separate performan...
1 answer
Gaseous ammonia (NH3) reacts with gaseous oxygen to form gaseous nitrogen monoxide and gaseous water. 11)...
Gaseous ammonia (NH3) reacts with gaseous oxygen to form gaseous nitrogen monoxide and gaseous water. 11) Un-thinkable (I'm Ready G gaseous water formula - GOL V Carbonic acid can form water and carbon dioxide upon heating. How much carbon dioxide is formed from 3.10 g of carbonic acid? H2CO3 H2...
1 answer
An occupational hazard research company conducted a retrospective cohort study on the relationship between asbestos exposure...
An occupational hazard research company conducted a retrospective cohort study on the relationship between asbestos exposure and mesothelioma in plumbers. There were two study groups — plumbers exposed to asbestos and plumbers not exposed to asbestos. An equal proportion (5%) of study particip...
1 answer
Question 10 (1 point) 10 510 1ES 16 Find the slope of the line if it...
Question 10 (1 point) 10 510 1ES 16 Find the slope of the line if it exists. 6 a b 1 6 с d 1...