Implement algorithm BuildHeapA Create an array A of size 7 w

Implement algorithm BuildHeap(A). Create an array A of size 7 with the following values: 12, 10, 15, 19, 8, 7, 20. Call BuildHeap(A). Output the resulting array.

Solution

#include #include class heap { int k[11],size; public: void getdata(void); friend void create_heap(heap &); void showdata(void); }; void heap :: getdata(void) { clrscr(); cout<<\"Enter the size of Array :-\"; cin>>size; cout<<\"\ Enter \"<>k[i]; } void heap :: showdata(void) { clrscr(); cout<<\"\ \ Heap Function Output\ \ \"; for(int i=1;i<=size;i++) cout<1 && key>a.k[j]) { a.k[i]=a.k[j]; i=j; j=i/2; if(j<1) j=1; } a.k[i]=key; } } void main() { heap o1; o1.getdata(); create_heap(o1); o1.showdata(); getch(); }
 Implement algorithm BuildHeap(A). Create an array A of size 7 with the following values: 12, 10, 15, 19, 8, 7, 20. Call BuildHeap(A). Output the resulting arra

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site