首页 > > 详细

讲解c#程序、asp.net语言辅导留学生、解析c#编程、c#讲解、讲解SLists 程序

COMP251 - Week3 - Lab
Jan 18, 2016
Goal:​ This lab will give you practice with linked lists.
Getting Started
You can have a partner for this lab, but make sure to submit to blackboard individually.

Downloadthefilesforthislabfromblackboard.ClassesSListandSListNodeimplement
a singly-linkedlist. CreateanemptyprojectinEclipseandcallit‘SList’.Addclasses:
SList, SListNode and TestHelper.
Run the test code with.

The​main()methodofSListincludestestcode,whichcanbeusedtohelpdebugthe
list code before SLists are used in other programs.

ReadSList.javatofindoutwhatmethodsareavailabletohelpyoumodifySLists.Items
in our SLists are indexed starting from 1, unlike Java arrays.


Part I: Using SLists (15 point)
-------------------------------
In the ​main()​ method, construct a list that looks like:
​[ 6 9 12 ]
and print the resulting list.

Add more lines to change this list to:
​[ 3 6 9 12 15 ]
and print the resulting list.


Part II: Adding to the End of a SList (45 points)
--------------------------------------------------
Amethodcalled​insertEnd()exists,butitrunsinlineartime,becauseeverytimeitis
called,it walksdownthelistto findtheend. Withoutchangingthemeaningofthis
methodoranyother,modifytherepresentationofa SListandwhatevermethodsare
necessary to make ​insertEnd()​ run in constant time.
YourSListclasswillneedtocontinuallymaintainarecordofthelast(tail)SListNodein
an SList, and all SList's methods will have to ensure that this record stays current.

Check-off
---------
ShowyourInstructororLabAssistantyour​main()and​insertEnd()methodsand
run the program.

1 point: your ​main()​ should print the proper output for Part I.
3 points:your​insertEnd()methodshouldworkin constanttime.Yourprogram
shouldstillprinttherightoutput(Youcanusetestcodeinthe​main()methodofSList
-- ​testEmpty()​, ​testAfterInsertFront()​, ​testAfterInsertEnd()​-- to test
your solution). Which other methods had to be modified?


Submission
---------
Create a single zip file of your project, submit to blackboard ​individually​ .

 

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!