You are on page 1of 1

10/30/2015

TheAceStudent:CS3330ProblemSet1:RecursionandComplexityAnalysis|CompleteSolution

CS3330ProblemSet1:RecursionandComplexityAnalysis|
CompleteSolution
CS3330ProblemSet1:RecursionandComplexityAnalysis|CompleteSolution
ProblemSet1:RecursionandComplexityAnalysisCS3330DataStructuresandAlgorithms
Overview:Forproblem1(a)ofthisassignment,youwillneedaC++compiler.Inordertoreceive
credit,yourprogrammustcompileandrunandyoumustprovidetheactualsourcecodefilesothat
Icancompileandrunyourprogram(e.g.thefileyoumodifiedendingin.cpp).Examplesonhowto
importexistingfilesintoyourcompilerareprovidedinthefilecalledImportingSourceCode.pdf.The
remainingproblemsfortheassignmentmustbewrittenupwithinasingleMicrosoftWorddocument.
Youmustincludeyournameandcoursenumberwithinallfilesthatyousubmit,includingsource
codefilesasacommentatthetopofeachfilethatyoucreateormodify.1.[7points]Recursion.
ReadtheassignedchapterandnotesforWeek1locatedintheLearningActivitiesareain
Blackboard.Thenprovidesolutionsforthefollowing:(a)[3points]Downloadthef.cppfile,then
usingthedefinitionbelow,implementthedetailsofarecursivefunctioncalledf(n).Thisfunctioncan
bedirectlytranslatedintoC/C++fromthefollowingmathematicaldefinition:(1)210(1)21000(
)fnnnfnnnnfnThefunctionmustbeimplementedbasedonthemathematicaldefinition
providedabove.Note:Forthisprogram,thefunctionmustuserecursion.Youonlyneedtomodify
theprovidedfilebyaddingthenecessarycodetoimplementtheTODOareasasnotedinthe
comments.Everythingelseintheprogramshouldremainthesame.Output:Theoutputforthis
programoncethefunctionisimplementedwillbeasfollows:f(44)is1936f(20)is400f(1)is1f(0)
is0f(1)is1f(13)is169f(20)is400f(50)is2500f(44)is1936**Pressanykeytocontinue**(b)[2
points]Brieflyexplainhowthefollowingrecursivefunctioncouldresultinaninfiniteloopandwhat
youcoulddotocorrectthis:(c)[2points]PerformanInternetsearchandprovideabriefdescription
(atleastaparagraphwithfourtofivesentences)ofanexampleofapracticaluseforrecursion.For
example,thepracticaluseyoumentionshouldbesomethingotherthansimplefunction
implementationssuchasfactorial,thepowerofanumber,Fibonacci,etc.Thedescriptionshouldbe
inyourownwords.IncludethereferencetoyoursourceorsourcesinAPAformatattheendofyour
description.2.[3points]ComplexityAnalysis.Beginbyreadingtheassignedchapterandnotesfor
Week2locatedintheLearningActivitiesareainBlackboard.Thenanswerthefollowingquestions:
(a)[2points]Brieflyexplainthedifferencebetweenbig(Omega)andbigOnotation.Alsoprovide
themathematicaldefinitionsofeach.(b)[1points]Whatistheasymptoticcomplexity(orbigO)of
thefollowingcodeblock?Brieflyexplainwhy.Note:Noprogrammingisnecessaryforthisproblem.
JusttellmewhatthebigOofthefunction,andprovideacoupleofsentencesexplaininghowyou
arrivedatthesolution.for(inti=0i<ni++){for(intj=0j<nj++){a[i][j]=0for(intk=0k<n
k++){a[i][j]+=b[i][k]*c[k][j]}}}OtherNotes:SubmityoursolutionsasasingleZipfileusingthe
ProblemSet1linkprovidedintheAssignmentsarea.IfyouareusingtheVisualC++orDevC++
compiler,youshouldonlysubmitthesourcecodefilesforyourprogram(thefilesendingin.cppand
.h).Forspacereasons,pleasedonotsubmittheentireVisualC++orDevC++projectfolders.Do
nothesitatetoaskifyouhaveanyquestionsorneedclarificationonwhattodoforthisassignment.
CS3330ProblemSet1:RecursionandComplexityAnalysis|CompleteSolution

data:text/htmlcharset=utf8,%3Ch3%20class%3D%22posttitle%20entrytitle%22%20itemprop%3D%22name%22%20style%3D%22margin%3A%200px

1/1

You might also like