Pages

Subscribe:

Labels

.

Effeck Saljou

Ads 468x60px

.
.

Rabu, 04 Januari 2012

coding AVL Tree


int main(){
                altree at;
                AVL NOde *avl = NULL;
                int h;
                cout << "insert 20\n";
                avl = at.insert(20, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 6\n";
                avl = at.insert(6, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 29\n";
                avl = at.insert(29, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 5\n";
                avl = at.insert(5, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 12\n";
                avl = at.insert(12, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 25\n";
                avl = at.insert(25, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 32\n";
                avl = at.insert(32, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 10\n";
                avl = at.insert(10, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 15\n";
                avl = at.insert(15, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 27\n";
                avl = at.insert(27, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 13\n";
                avl = at.insert(13, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "Delete 20\n";
                avl = at.deldata (avl, 20, &h);
                at.setroot(avl)
                cout << endl <<"AVL tree after deletion of a node 20:\n";
                at.display(avl);
                system("PAUSE");
                cout << "Delete 12\n";
                avl = at.deldata (avl, 12, &h);
                at.setroot(avl)
                cout << endl <<"AVL tree after deletion of a node 20:\n";
                at.display(avl);
                system("PAUSE");
                cout << "insert 2\n";
                avl = at.insert(2, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 28\n";
                avl = at.insert(28, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 20\n";
                avl = at.insert(20, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 8\n";
                avl = at.insert(8, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "Delete 15\n";
                avl = at.deldata (avl, 15, &h);
                at.setroot (avl)
                cout << endl <<"AVL tree after deletion of a node 15:\n";
                at.display(avl);
                system("PAUSE");
                cout << "Delete 6\n";
                avl = at.deldata (avl, 6, &h);
                at.setroot (avl)
                cout << endl <<"AVL tree after deletion of a node 6:\n";
                at.display(avl);
                system("PAUSE");
                cout << "Delete 5\n";
                avl = at.deldata (avl, 5, &h);
                at.setroot (avl)
                cout << endl <<"AVL tree after deletion of a node 5:\n";
                at.display(avl);
                system("PAUSE");
                cout << "Delete 13\n";
                avl = at.deldata (avl, 13, &h);
                at.setroot*avl)
                cout << endl <<"AVL tree after deletion of a node 13:\n";
                at.display(avl);
                system("PAUSE");
                cout << "Delete 10\n";
                avl = at.deldata (avl, 10, &h);
                at.setroot (avl)
                cout << endl <<"AVL tree after deletion of a node 10:\n";
                at.display(avl);
                system("PAUSE");
                cout << "insert 22\n";
                avl = at.insert(22, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");
                cout << "insert 23\n";
                avl = at.insert(23, &h);
                at.setroot(avl);
                at.display(avl);
                system("PUASE");

Tidak ada komentar:

Posting Komentar