algorithms & data structures practice test / quiz and need the explanation and answer to help me learn.
All assignments must useJava 17 LTS, the latest long-term support release for the Java SE platform. As a development environment, the use of IntelliJ IDEA is required.
Requirements: 123 | Java
CSE214:DataStructures(Fall2023)–AssignmentIInstructor:Dr.RitwikBanerjeeComputerScience,StonyBrookUniversityThisassignmentconsistsoftwoparts,and6pages.Studentsarerequiredtofollowthedevelopmentenvi-ronmentdescribedforthiscourse.Anycodeprovidedtoyouaspartofthisassignmentcanbefoundintheappendixsectionsofthisdocument.Thisassignmentisdueby11:59pm,Sep22(Friday).Rememberthatwheneveryouareimplementingadatastructurecorrespondingtoanabstractdatatype,youcanwriteadditionalmethodsthatarenotrequiredbytheinterface.Theseadditionalmethods,however,arenotapartofthedatatype’s“contract”,andtherefore,mustbeprivate.I.LinkedListTostartoff,youmustimplementausableDoublyLinkedListgenericclass.Weusethisnametoavoidanyconfusionwiththebuilt-inclassprovidedbytheJavalibrary.Afullyfunctioningimplementationrequiresthreeclasses:1.TheDoublyLinkedListclass,whereeachnodemaintainsanextandapreviousreference.ThisclassmustimplementtheListAbstractTypeinterfaceprovidedtoyouaspartofthisassignment(andNOTthebuilt-inlistinterfaceprovidedinJava’slibrary).2.ANodeclass,whichmustbeaprivatestaticclassnestedinsideDoublyLinkedList.3.ADoublyLinkedListIteratorclass,whichmustimplementtheTwoWayListIteratorinterfacepro-videdtoyouaspartofthisassignment.1.(5)TheNodeclasswithitsfieldsandconstructor:TheveryfirststepistounderstandhowtowritetheNodeclassasaprivateclassnestedinsideDoublyLinkedList.Nestedclassescanbestaticornon-static,butinthisassignmentyouwillhavetouseastaticnestedclass.TheNodeclasswillneverbedirectlyusedbyanyexternalclientcode,sofieldsofthisclasscanbepublic(remember,theentireclassisnestedandprivate,sothesefieldscannotbeaccessedexternallyeveniftheyareindividuallydeclaredtobeanythingotherthanprivate).TocreateaDoublyLinkedListwithanyelements,however,youwillneedtowriteaconstructorforthisNodeclass,andanyNodeinstancemusthaveanextandapreviousreferencealongwithitsownelement.2.(15)ImplementingtheCollectionTypemethods:Aswehavediscussedinthelectures,thedatastructureisacompleteimplementationofanabstractdatatype.Inthisassignment,yourDoublyLinkedListdatastructuremustimplementtheListAbstractTypeinterface.Butthisdatatype,inturn,extendstheCollectionTypeinterface.Thus,youmustimplementthefollowingmethodssothattheyfunctioncorrectlyasperthedocumentationprovidedintheCollectionTypeinterfacecode:booleanadd(Eelement);booleanremove(Eelement);intsize();booleanisEmpty();booleancontains(Eelement);3.(15)ImplementingtheListAbstractTypemethods:TheDoublyLinkedListclasswill,ofcourse,alsoneedtoimplementtheotheradditionalmethodsdeclaredintheListAbstractTypeinterface.Thesemethodsaremorespecifictotheconceptofasequentialcollectionofelements,andtherefore,useofanelement’s“position”inalist.YoumustimplementthefollowingmethodssothattheyfunctioncorrectlyasperthedocumentationintheListAbstractTypeinterfacecode:1
CSE214:DataStructures(Fall2023)AssignmentIEget(intindex);Eset(intindex,Eelement);voidadd(intindex,Eelement);voidremove(intindex);4.(15)Implementingatwo-wayiterator:Inquestion1,wedidnotincludeoneveryimportantmethod,whichisinheritedfromthejava.lang.Iterableinterface.Inyourentireimplementationofadoublylinkedlist,IterableistheonlyinterfacereadilyavailablefromacoreJavalibrary(unliketheothertwobuiltseparatelyforthisassignment:CollectionTypeandListAbstractType).TheIterableinterfacerequiresimplementatingamethoddeclaredasIterator
CSE214:DataStructures(Fall2023)AssignmentIForbothimplementations,youcanassumethatthegamewillbeplayedwithatleasttwoplayers(i.e.,N>1),andthatthelengthofthepasswillalwaysbeanon-negativevalue(i.e.,M≥0).Reallyimportantnotes1.Thecorrectnessofyourcodewillbetestedwithvarioustestcases,andNOTbyreadingthroughyourcode.Inlectures,wehavediscussedtheroleofa“client”code.Forthisassignment(andfutureassignmentsinthiscourse),youshouldthinkofthegrader’scodeasaclientcode.Forexample,thegraderwilltesttheset(intindex,Eelement)methodbycreatingalistusingyouradd(Eelement)methodafewtimes,andthencallingthesetmethod.Thegraderwillnotreadyourcodeline-by-linetoassessitscorrectness!2.Donotthinkofthisassignmentasanimplementationofindividualmethodsputtogether.Manymethodsareinterrelated,andincorrectimplementationofonemethodmayaffectthepointsobtainedinotherplaces.Forexample,ifyouradd(Eelement)methoddoesnotwork,thegradercannotevencreatealistwithyourcode.Inthatcase,thegradersimplycannotgradeanyoftheothermethodseither!Another(lessdrastic)exampleofsuchinterdependence:thesize()methodcanonlybedeemedcorrectifitreportsthecorrectsizeofalistafterseveralcombinationsofadditionsandremovals.So,mistakesintheadd(Eelement)and/ortheremove(Eelement)methodscanaffectthepointsobtainedforthesize()method(e.g.,addtwoitemstoanemptylist,thenremoveoneitem,butacallstosize()stillreturns2).3.TheHotPotatocodealsoshowsyouhowthemainmethodwillcallyourimplementationsofthegame,andtheexpectedoutputs.Theprovidedmainmethodthusservesasaverybasicclientcode,withtwotestcases.Studentsareexpectedtotesttheirowncodewithasmanytestcasesastheywant.4.Anicestringrepresentationofyourlinkedlistmaybeveryusefulfortestingyourowncode,andprintingouttheliststhatyouobtainaftervariousoperations.Toaidyouwiththis,thetoString()methodisprovidedintheappendix.PleaseincludethismethodexactlyasprovidedinyourDoublyLinkedListclass.Whengrading,thismethodwillbeexpectedtobeincluded,anditwillbecalledtotesttherestofyourcodeforthisclass.5.Itmightbehelpfultorememberthatthereisaveryeasywaytotestifyouhaveimplementedtheiter-ator:ifyoucannotuseanenhancedforloop(alsocalledthefor-eachloop)onyourDoublyLinkedList,thatmeansyouhavenotimplementedaniteratorproperly.Averysimpleclientcodefortestingmaybesomethinglikepublicstaticvoidmain(String…args){DoublyLinkedList
CSE214:DataStructures(Fall2023)AssignmentIpublicinterfaceCollectionType
CSE214:DataStructures(Fall2023)AssignmentI**@paramindexthespecifiedposition*@paramelementthespecifiedelementtobeadded*/voidadd(intindex,Eelement);/***Removestheelementatthespecifiedposition.**@paramindexthespecifiedposition*/voidremove(intindex);}AppendixC:TwoWayListIterator.javapackagecse214hw1;importjava.util.Iterator;importjava.util.NoSuchElementException;/***DONOTMODIFYTHISCODE!!*@authorRitwikBanerjee*/publicinterfaceTwoWayListIterator
CSE214:DataStructures(Fall2023)AssignmentI*@throwsUnsupportedOperationExceptionifthe{@codeset}operationisnot*supportedbythislistiterator*@throwsIllegalStateExceptionifneither{@codenext}nor{@codeprevious}*havebeencalled,or{@coderemove}or*{@codeadd}havebeencalledafterthelast*callto{@codenext}or{@codeprevious}*/voidset(Eelement);}AppendixD:PrintingaDoublyLinkedList@OverridepublicStringtoString(){Iterator
We are a professional custom writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework.
Yes. We have posted over our previous orders to display our experience. Since we have done this question before, we can also do it for you. To make sure we do it perfectly, please fill our Order Form. Filling the order form correctly will assist our team in referencing, specifications and future communication.
1. Click on the “Place order tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
2. Fill in your paper’s requirements in the "PAPER INFORMATION" section and click “PRICE CALCULATION” at the bottom to calculate your order price.
3. Fill in your paper’s academic level, deadline and the required number of pages from the drop-down menus.
4. Click “FINAL STEP” to enter your registration details and get an account with us for record keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
5. From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.
Need this assignment or any other paper?
Click here and claim 25% off
Discount code SAVE25