cs141

profilealihhhh
Assignment3CRN21951home.pdf

CollegeofComputingandInformatics

Assignment3 Deadline:07/04/2018@ 23:59

[TotalMarkforthisAssignmentis20/5=4]

Instructions:

 ThisAssignmentmustbesubmittedonBlackboard(WORDformatonly)viatheallocated

folder.

 Emailsubmissionwillnotbeaccepted.

 Youareadvisedtomakeyourworkclearandwell-presented,marksmaybereducedfor

poorpresentation.Thisincludesfillingyourinformationonthecoverpage.

 YouMUSTshow allyourwork,andtextmustnotbeconvertedintoanimage,unless

specifiedotherwisebythequestion.

 LatesubmissionwillresultinZEROmarksbeingawarded.

 Theworkshouldbeyourown,copyingfrom studentsorotherresourceswillresultin

ComputerProgrammingII

CS141

Pg.1 QuestionThree

QuestionOne ExplainhowwecanapplyBinarySearchalgorithm either

directlyorindirectlyinthefollowingcases:

a) Array1isanarrayofsortedintegers numbers:

(Youmustchooseanelementtoshowthesteps)

Learning

Outcome(s):

Understandand

beabletoapply

binarysearch

algorithm in

differentcases

8Marks

Array1:

1 5 7 13 16 22 38 55 70 90

Pg.2 QuestionThree

,

b)Array2isanarrayofunsortedintegersnumbers: (Youcanchooseanelementtoshowthesteps)

c)Array3isanarrayofStrings: Theorderofsortingisalphabetical(e.g.“AA”before“BC”and“AA” before“AB”). (Youcanchooseanelementtoshowthesteps)

Array2:

300 20 121 30 110 25 122 200 250 20

Array3:

“AA” “AB” “BA” “BC” “CN” “FA” “KF” “LZ” “MN” “ZN”

Pg.3 QuestionThree

Pg.4 QuestionThree

QuestionTwo A) Describethelinkedlistdatastructureandtheuseoflistiterators.

B) Whyiteratorsarenotneededwitharrays?

.

Learning

Outcome(s):

Understandwhat

thelinkedlistis

andhowto

implement

iterators.

5Marks

Pg.5 QuestionThree

QuestionThree Byusingalinkedlist,writeafunctionremoveEvensthatwillremoveanyeven

numberthatwillcomeafteranevennumberinthelist.Forexplanation,you

canseethegivenexamples:

Learning

Outcome(s):

Createand

manipulate

dynamicdata

structures,such

uslinkedlists,

stacksand

queues,and

binarytrees.

7Marks