purwita sari tkj5a

Upload: andika-dwi-putra

Post on 09-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

NAMA : PURWITA SARIKELAS : TKJ5A

#include

using namespace std;

struct Tree{int data;Tree* Right;Tree* Left; };

int main(){ Tree* Root = NULL; Tree* a = NULL; Tree* b = NULL; Tree* c = NULL; Tree* d = NULL; Tree* e = NULL; Tree* f = NULL; Tree* g = NULL; Tree* h = NULL; Tree* i = NULL; Tree* j = NULL; Tree* Current = NULL; Tree* RightBranch = NULL; Tree* LeftBranch = NULL;

Root = new Tree; RightBranch = new Tree; a = new Tree; b = new Tree; c= new Tree; d= new Tree; e= new Tree; f= new Tree; g= new Tree; h= new Tree; i= new Tree; j= new Tree; LeftBranch = new Tree; Current = new Tree;

Root->data = 0; Root->Left = b; Root->Right = c; b->data = 1; b->Left = d; b->Right = e; c->data = 2; c->Left = f; c->Right = g;

d->data = 3; d->Left = h; d->Right = i;

e->data = 4; e->Left = j; e->Right = NULL; f->data = 5; f->Left = NULL; f->Right = NULL; g->data = 6; g->Left = NULL; g->Right = NULL; h->data = 7; h->Left = NULL; h->Right = NULL; i->data = 8; i->Left = NULL; i->Right = NULL; j->data = 9; j->Left = NULL; j->Right = NULL; return 0;}