Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 21 Jul 2017 My Price 13.00

traversal algorithms

This example shows how to pass a user-defined function as a parameter to the binary tree traversal algorithms. For illustration purposes, we show how to use only the inorder traversal function. The following program uses the class bSearchTreeType, which is derived from the class binaryTreeType, to build the binary tree. The traversal functions are included in the class binaryTreeType, which are then inherited by the class bSearchTreeType.

#include <iostream>

#include "binarySearchTree.h"

using namespace std;

void print(int& x);

void update(int& x);

int main()

{

bSearchTreeType<int> treeRoot; //Line 1

int num; //Line 2

cout << "Line 3: Enter numbers ending "

<< "with -999." << endl; //Line 3

cin >> num; //Line 4

while (num != -999) //Line 5

{

treeRoot.insert(num); //Line 6

cin >> num; //Line 7

}

cout << endl

<< "Line 8: Tree nodes in inorder: "; //Line 8

treeRoot.inorderTraversal(print); //Line 9

cout << endl << "Line 10: Tree Height: "

<< treeRoot.treeHeight()

<< endl << endl; //Line 10

cout << "Line 11: ******* Update Nodes "

<< "*******" << endl; //Line 11

treeRoot.inorderTraversal(update); //Line 12

cout << "Line 13: Tree nodes in inorder "

<< "after the update: " << endl

<< " "; //Line 13

treeRoot.inorderTraversal(print); //Line 14

cout << endl << "Line 15: Tree Height: "

<< treeRoot.treeHeight() << endl; //Line 15

return 0; //Line 16

}

void print(int& x) //Line 17

{

cout << x << " "; //Line 18

}

void update(int& x) //Line 19

{

x = 2 * x; //Line 20

Answers

(5)
Status NEW Posted 21 Jul 2017 08:07 AM My Price 13.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â-----------  -----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------sol-----------uti-----------on.-----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- ca-----------tch-----------

Not Rated(0)