欢迎来到天天文库
浏览记录
ID:34110431
大小:191.12 KB
页数:25页
时间:2019-03-03
《数据结构与算法分析 第8章 答案 larry nyhoff 清华大学出版社》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Chapter8Chapter8:QueuesExercises8.21.2.q01234q01234myArrayABCA?myArrayXYZ??myFront1myBack4myFront3myBack3Queueisnowempty3.4.q01234q01234myArraysrqrrmyArrayCAABBmyFront3myBack1myFront4myBack3Erroroccurswheni=4.Afterch='A'isinsertedinlocation2,myBackis3andmyFrontis4,whichmeansth
2、equeueisfull,sothenextenqueue()operationfails.5./*--DQueue.h------------------------------------------------------ThisheaderfiledefinesaQueuedatatype.Basicoperations:constructor:Constructsanemptyqueuecopyconstructor:Constructsacopyofaqueue=:Assignmentoperatordestructor:Destroy
3、saqueueempty:Checksifaqueueisemptyenqueue:Modifiesaqueuebyaddingavalueatthebackfront:Accessesthetopstackvalue;leavesqueueunchangeddequeue:Modifiesqueuebyremovingthevalueatthefrontdisplay:Displaysallthequeueelements---------------------------------------------------------------
4、----*/#include#ifndefDQUEUE#defineDQUEUEtypedefintQueueElement;–71–Chapter8classQueue{public:/*****Functionmembers*****//*****Constructors*****/Queue(intnumElements=128);/*----------------------------------------------------------ConstructaQueueobject.Precondition:No
5、ne.Postcondition:AnemptyQueueobjecthasbeenconstructed(myFrontandmyBackareinitializedto0andmyArrayisanarraywithnumElements(default128)elementsoftypeQueueElement).-----------------------------------------------------------*/Queue(constQueue&original);/*--------------------------
6、--------------------------------CopyConstructorPrecondition:originalisthequeuetobecopiedandisreceivedasaconstreferenceparameter.Postcondition:Acopyoforiginalhasbeenconstructed.-----------------------------------------------------------*//*****Destructor*****/~Queue();/*-------
7、---------------------------------------------------ClassdestructorPrecondition:NonePostcondition:Thedynamicarrayinthequeuehasbeendeallocated.-----------------------------------------------------------*//*****Assignment*****/constQueue&operator=(constQueue&rightHandSide);/*----
8、------------------------------------------------------Assignm
此文档下载收益归作者所有