Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/* Linked List */ #include <iostream> #include <memory> #include <string> #inclu

ID: 3547503 • Letter: #

Question

/* Linked List */


#include <iostream>

#include <memory>

#include <string>

#include <sstream>


using namespace std;


string convertIntToString(int);



class Anode {




public:


int data;

shared_ptr<Anode> left;

shared_ptr<Anode> right;


Anode(int);

// string LDR(); I used these - you might not

//string DLR();

//int sum();


};



// -----------------------------------------------//

// //

// //

// T R E E C L A S S //

// //

// //

// ToDo: //

// write LDR method //

// write DLR method //

// write sum method //

// //

// //

// -----------------------------------------------//



class Tree {

shared_ptr<Anode> root;


public:


void bootstrap();

Tree();

void LDR(); // process left subtree; process current node data; process right subtree

void DLR(); // process current node data; process left subtree; process right subtree

int sum(); // return the sum of all the node data in the tree


};


Anode::Anode(int num){

data = num;

}



Tree::Tree(){

bootstrap();

}


void Tree::bootstrap(){

root = make_shared<Anode>(50);

shared_ptr<Anode> b = make_shared<Anode>(25);

shared_ptr<Anode> c = make_shared<Anode>(75);

shared_ptr<Anode> d= make_shared<Anode>(15);

shared_ptr<Anode> e = make_shared<Anode>(35);

shared_ptr<Anode> f = make_shared<Anode>(65);

shared_ptr<Anode> g = make_shared<Anode>(85);

shared_ptr<Anode> h = make_shared<Anode>(10);

shared_ptr<Anode> i = make_shared<Anode>(20);

shared_ptr<Anode> j = make_shared<Anode>(30);

shared_ptr<Anode> k = make_shared<Anode>(40);

shared_ptr<Anode> l = make_shared<Anode>(60);

shared_ptr<Anode> m = make_shared<Anode>(70);

shared_ptr<Anode> n = make_shared<Anode>(80);

shared_ptr<Anode> o = make_shared<Anode>(90);

// now connect them

root->left = b;

root->right = c;

b->left = d;

b->right = e;

d->left = h;

d->right = i;

e->left = j;

e->right = k;

c->left = f;

c->right = g;

f->left = l;

f->right = m;

g->left = n;

g->right = o;

}



// -----------------------------------------------//

// //

// //

// M A I N //

// //

// //

// -----------------------------------------------//



string convertIntToString(int i){

ostringstream convert;

convert << i;

return convert.str();

}


int main(){

shared_ptr<Tree> aTree = make_shared<Tree>();

aTree->bootstrap();

//cout << "LDR Order ";

//aTree->LDR();



//cout << " DLR Order ";

//aTree->DLR();


//cout << " SUM ";

//cout << aTree->sum() << endl;

}

Explanation / Answer

this programme is basically converting integer array to string.


What more you expect in this programme, where you are not able to understand the c++ code.,