-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathp1.cpp
More file actions
34 lines (24 loc) · 846 Bytes
/
Copy pathp1.cpp
File metadata and controls
34 lines (24 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "ADTBiTree.cpp"
#include<sstream>
int main(){
BiTree<char> b;
b.create(istringstream("ABD#G###CE##F##"));
cout<<"b is created by \"ABD#G###CE##F##\""<<endl;
cout<<"depth(b)="<<b.depth()<<endl;
cout<<"root(b): "<<b.getRoot()<<endl;
cout<<"LeftChild of A: "<<b.leftChild(b.root)->data<<endl;
cout<<"RightBrother of B: "<<b.rightBrother(b.root->lchild)->data<<endl;
cout<<"InOrderTraverse(b): ";
b.inOrderTraverse([](auto e){cout<<e<<' ';});
cout<<endl;
cout<<"assign 'H' to root"<<endl;
b.assign(b.root,'H');
cout<<"erase left child of root"<<endl;
b.erase(b.root,0);
cout<<"LevelOrderTraverse(b): ";
b.levelOrderTraverse([](auto e){cout<<e<<' ';});
cout<<endl;
b.clear();
cout<<"b is cleared"<<endl<<"b is empty: "<<b.empty()<<endl;
return 0;
}