/* * Main Contains Menu */ int main() { int n, m, l, i; BinomialHeap bh; node* p; node *H; H = bh.Initializeheap(); char ch; while (1) { cout<<"----------------------------"<<endl; cout<<"Operations on Binomial heap"<<endl; cout<<"----------------------------"<<endl; cout<<"1)Insert Element in the heap"<<endl; cout<<"2)Extract Minimum key node"<<endl; cout<<"3)Decrease key of a node"<<endl; cout<<"4)Delete a node"<<endl; cout<<"5)Display Heap"<<endl; cout<<"6)Exit"<<endl; cout<<"Enter Your Choice: "; cin>>l; switch(l) { case 1: cout<<"Enter the element to be inserted: "; cin>>m; p = bh.Create_node(m); H = bh.Insert(H, p); break; case 2: p = bh.Extract_Min(H); if (p != NULL) cout<<"The node with minimum key: "<<p->n<<endl; else cout<<"Heap is empty"<<endl; break; case 3: cout<<"Enter the key to be decreased: "; cin>>m; cout<<"Enter new key value: "; cin>>l; bh.Decrease_key(H, m, l); break; case 4: cout<<"Enter the key to be deleted: "; cin>>m; bh.Delete(H, m); break; case 5: cout<<"The Heap is: "<<endl; bh.Display(H); break; case 6: exit(1); default: cout<<"Wrong Choice"; } } return 0; }
int main() { cout<<"Binomial Heap\n\n"; BinomialHeap bh; char ch; int val; /* Perform BinomialHeap operations */ do { cout<<"1. Insert "<<endl; cout<<"2. Delete "<<endl; cout<<"3. Size"<<endl; cout<<"4. Check empty"<<endl; cout<<"5. Clear"<<endl; int choice; cout<<"Enter your Choice: "; cin>>choice; switch (choice) { case 1 : cout<<"Enter integer element to insert: "; cin>>val; bh.insert(val); break; case 2 : cout<<"Enter element to delete: "; cin>>val; bh.Delete(val); break; case 3 : cout<<"Size = "<<bh.getSize()<<endl; break; case 4 : cout<<"Empty status = "; if (bh.isEmpty()) cout<<"Heap is empty"<<endl; else cout<<"Heap is non - empty"<<endl; break; case 5 : bh.makeEmpty(); cout<<"Heap Cleared\n"; break; default : cout<<"Wrong Entry \n "; break; } /* Display heap */ bh.displayHeap(); cout<<"\nDo you want to continue (Type y or n) \n"; cin>>ch; } while (ch == 'Y'|| ch == 'y'); return 0; }