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
#include
template
{
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.*/virtualvector
};//endBagInterface
#endif
#include
#ifndef_HEAP_INTERFACE#define_HEAP_INTERFACE
template
{
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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started