Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DS Finals' Laboratory

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

FINALS’ LABORATORY | BST

#include <iostream> queue<char>qq;


#include <queue>
using namespace std; qq.push('J');
qq.push('H');
class TreeNode { qq.push('E');
public: qq.push('R');
int data; qq.push('R');
TreeNode* left; qq.push('Y');
TreeNode* right;
int Ee=7;
TreeNode(int value) : data(value), left(NULL), right(NULL) {} TreeNode* root = createNode(Ee);
}; insertRight(root, Ee);
qq.pop();
TreeNode* createNode(int data) {
return new TreeNode(data); while(!qq.empty()){
}
if(qq.front()=='H'){
void insertLeft(TreeNode* parent, int data) { int Le=6;
insertRight(root, Le);
if (parent) { qq.pop();
parent->left = createNode(data); }else if(qq.front()=='E'){
cout <<data; int Oe=2;
} insertLeft(root->right, Oe);
} qq.pop();
}else if(qq.front()=='R'){
void insertRight(TreeNode* parent, int data) { int Ne=1;
if (parent) { insertRight(root->right, Ne);
parent->right = createNode(data); qq.pop();
cout <<data; }
} else if(qq.front()=='I'){
} int Ge=8;
insertLeft(root->right, Ge);
int main() { qq.pop();
}
else if(qq.front()=='Y'){
int Ge=9;
insertLeft(root, Ge);
qq.pop();
}
}

return 0;
}

You might also like