Professional Documents
Culture Documents
DS Final Project (Pre)
DS Final Project (Pre)
#include <queue>
using namespace std;
class TreeNode {
public:
int data;
TreeNode* left;
TreeNode* right;
int main() {
queue<char>qq;
qq.push('J');
qq.push('H');
qq.push('E');
qq.push('R');
qq.push('R');
qq.push('Y');
int Ee=7;
TreeNode* root = createNode(Ee);
insertRight(root, Ee);
qq.pop();
while(!qq.empty()){
if(qq.front()=='H'){
int Le=6;
insertRight(root, Le);
qq.pop();
}else if(qq.front()=='E'){
int Oe=2;
insertLeft(root->right, Oe);
qq.pop();
}else if(qq.front()=='R'){
int Ne=1;
insertRight(root->right, Ne);
qq.pop();
}
else if(qq.front()=='I'){
int Ge=8;
insertLeft(root->right, Ge);
qq.pop();
}
else if(qq.front()=='Y'){
int Ge=9;
insertLeft(root, Ge);
qq.pop();
}
}
if (root) {
inorderTraversal(root->left);
cout << root->data << " ";
inorderTraversal(root->right);
}
return 0;
}