Exemplo n.º 1
0
int main (){
	PriorityQueue *m = new PriorityQueue();
	arrayList *a = new arrayList();
	for (int i = 0; i < 10; i++)
    	 	a->insert(i, 10-i);
	m->initialize(a, 10);
	cout<<"The inorder travesal is: ";
	m->inOrder(0);
	cout<<endl;
	cout<<"The preorder travesal is: ";
	m->preOrder(0);
	cout<<endl;
	cout<<"The postorder travesal is: ";
	m->postOrder(0);
	cout<<endl;
	cout<<"The sorted list is: ";
	m->sort();
	cout<<endl;

}
Exemplo n.º 2
0
int main (){
	PriorityQueue *m = new PriorityQueue();
	arrayList *a = new arrayList();
	for (int i = 0; i < 10; i++)
    	 	a->insert(i, 10-i);

    arrayList *b = new arrayList();
	for (int j = 0; j < 20; j++)
    	 	b->insert(j, 20-j);

    arrayList *c = new arrayList();
	for (int i = 0; i < 17; i++)
    	 	c->insert(i, i%7);



	m->initialize(a, 10); //Make priority queue
	//m->initialize(b, 20); //Make priority queue
	//m->initialize(c, 17); //Make priority queue


	m->print();
	cout<<"The inorder travesal is: ";
	m->inOrder(0);
	cout<<endl;
	cout<<"The preorder travesal is: ";
	m->preOrder(0);
	cout<<endl;
	cout<<"The postorder travesal is: ";
	m->postOrder(0);
	cout<<endl;
	cout<<"The sorted list is: ";
	m->sort();
	cout<<endl; 

}