Question: implement ArrayMaxHeap Extend HeapInterface and BagInterface class. use the all the files given and implement a driver to demonstrate all the necessary functions. #ifndef_BAG_INTERFACE#define_BAG_INTERFACE #include

implement ArrayMaxHeap

Extend HeapInterface and BagInterface class. use the all the files given and implement a driver to demonstrate all the necessary functions.

#ifndef_BAG_INTERFACE#define_BAG_INTERFACE

#includeusingnamespacestd;

templateclassBagInterface

{

public:

/**Getsthecurrentnumberofentriesinthisbag.

@returnTheintegernumberofentriescurrentlyinthebag.*/virtualintgetCurrentSize()const=0;

/**Seeswhetherthisbagisempty.

@returnTrueifthebagisempty,orfalseifnot.*/virtualboolisEmpty()const=0;

/**Addsanewentrytothisbag.

@post Ifsuccessful,newEntryisstoredinthebagandthecountofitemsinthebaghasincreasedby1.@paramnewEntry Theobjecttobeaddedasanewentry.

@return Trueifadditionwassuccessful,orfalseifnot.*/virtualbooladd(constItemType&newEntry)=0;

/**Removesoneoccurrenceofagivenentryfromthisbag,ifpossible.

@post Ifsuccessful,anEntryhasbeenremovedfromthebagandthecountofitemsinthebaghasdecreasedby1.

@paramanEntry Theentrytoberemoved.

@return Trueifremovalwassuccessful,orfalseifnot.*/virtualboolremove(constItemType&anEntry)=0;

/**Removesallentriesfromthisbag.

@post Bagcontainsnoitems,andthecountofitemsis0.*/virtualvoidclear()=0;

/**Countsthenumberoftimesagivenentryappearsinbag.@paramanEntry Theentrytobecounted.

@return ThenumberoftimesanEntryappearsinthebag.*/virtualintgetFrequencyOf(constItemType&anEntry)const=0;

/**Testswhetherthisbagcontainsagivenentry.@paramanEntry Theentrytolocate.

@return TrueifbagcontainsanEntry,orfalseotherwise.*/virtualboolcontains(constItemType&anEntry)const=0;

/**Emptiesandthenfillsagivenvectorwithallentriesthatareinthisbag.

@return Avectorcontainingalltheentriesinthebag.*/virtualvectortoVector()const=0;

};//endBagInterface

#endif

#include#include#includeusingnamespacestd;

#ifndef_HEAP_INTERFACE#define_HEAP_INTERFACE

templateclassHeapInterface

{

public:

/**Seeswhetherthisheapisempty.

@returnTrueiftheheapisempty,orfalseifnot.*/virtualboolisEmpty()const=0;

/**Getsthenumberofnodesinthisheap.@returnThenumberofnodesintheheap.*/

virtualintgetNumberOfNodes()const=0;

/**Getstheheightofthisheap.@returnTheheightoftheheap.*/virtualintgetHeight()const=0;

/**Getsthedatathatisintheroot(top)ofthisheap.Foramaxheap,thedataisthelargestvalueintheheap;foraminheap,thedataisthesmallestvalueintheheap.@preTheheapisnotempty.

@postTherootsdatahasbeenreturned,andtheheapisunchanged.@returnThedataintherootoftheheap.*/

virtualItemTypepeekTop()const=0;

/**Addsanewnodecontainingthegivendatatothisheap.@paramnewDataThedataforthenewnode.

@postTheheapcontainsanewnode.

@returnTrueiftheadditionissuccessful,orfalseifnot.*/virtualbooladd(constItemType&newData)=0;

/**Removestherootnodefromthisheap.

@returnTrueiftheremovalissuccessful,orfalseifnot.*/virtualboolremove()=0;

/**Removesallnodesfromthisheap.*/virtualvoidclear()=0;

};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!