欢迎来到天天文库
浏览记录
ID:38523545
大小:296.50 KB
页数:11页
时间:2019-06-14
《服务计算概论作业报告》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、2016-2017-1慕测平台测试报告慕测平台测试报告(二)学院:计算机学院姓名:赵红娜专业:软件工程学号:3130608003班级:1301完成日期:2016-10-222016年10月22日112016-2017-1慕测平台测试报告1.题目针对以下4个项目编写测试用例进行测试。代码如下:题目(1)112016-2017-1慕测平台测试报告//BinaryHeapclass////CONSTRUCTION:withoptionalcapacity(thatdefaultsto100)////******************PUBLICOPERATIONS********
2、*************//voidinsert(x)-->Insertx//intdeleteMin()-->Returnandremovesmallestitem//intfindMin()-->Returnsmallestitem//booleanisEmpty()-->Returntrueifempty;elsefalse//booleanisFull()-->Returntrueiffull;elsefalse//voidmakeEmpty()-->Removeallitems//******************ERRORS******************
3、**************//ThrowsOverflowifcapacityexceeded/***Implementsabinaryheap.*Notethatall"matching"isbasedonthecompareTomethod.*@authorMarkAllenWeiss*/publicclassBinaryHeap{//@invariantwellFormed();/***Constructthebinaryheap.*/publicBinaryHeap(){this(DEFAULT_CAPACITY);}/***Constructthebinaryhe
4、ap.*@paramcapacitythecapacityofthebinaryheap.*///@requirescapacity>0;//@ensuresisEmpty();publicBinaryHeap(intcapacity){currentSize=0;array=newint[capacity+1];}/***Insertintothepriorityqueue,maintainingheaporder.*Duplicatesareallowed.*@paramxtheitemtoinsert.*@exceptionOverflowifcontainerisfu
5、ll.*/publicvoidinsert(intx)throwsOverflow{if(isFull())thrownewOverflow();//Percolateupinthole=++currentSize;for(;hole>1&&x6、ublicintfindMin(){if(isEmpty())return-1;returnarray[1];}booleanwellFormed(){if(array==null){//array!=nullreturnfalse;}if(currentSize<07、8、currentSize>=array.length){//currentSize>=0;currentSizearray[2*i]){r9、eturnfalse;}if(i*2+1<=currentSize&&array[i]>array[2*i+1]){returnfalse;}}returntrue;}/***Removethesmallestitemfromthepriorityqueue.*@returnthesmallestitem,ornull,ifempty.*/publicintdeleteMin(){if(isEmpty())return-1;intminItem=findMin();array[1]=array[curr
6、ublicintfindMin(){if(isEmpty())return-1;returnarray[1];}booleanwellFormed(){if(array==null){//array!=nullreturnfalse;}if(currentSize<0
7、
8、currentSize>=array.length){//currentSize>=0;currentSizearray[2*i]){r
9、eturnfalse;}if(i*2+1<=currentSize&&array[i]>array[2*i+1]){returnfalse;}}returntrue;}/***Removethesmallestitemfromthepriorityqueue.*@returnthesmallestitem,ornull,ifempty.*/publicintdeleteMin(){if(isEmpty())return-1;intminItem=findMin();array[1]=array[curr
此文档下载收益归作者所有