Microsoft Word - BCS230_Lab12_handout_update.docx Lab12-BCS230,M.Alrajab 1 BCS230 Lab12HandoutandAssignment This lab handout provides tasks that students are required to attempt during lab...

All knowledge should relate to the text C++ early objects (Chapter 1- 11,14 and 16)ninth edition written by Gaddis and please add comments to explain the solution


Microsoft Word - BCS230_Lab12_handout_update.docx Lab12-BCS230,M.Alrajab 1 BCS230 Lab12HandoutandAssignment This lab handout provides tasks that students are required to attempt during lab session. Lab objectives are for students to practice with recursion, pointers and algorithms. Task1: ReviewanddiscussionrelatetoQuiz2. Task2: Step1:Modifythefollowingrecursivefunctiontofindthesumofallnumbersthat aremultiplesof5from0to100. Step2:Deletethelocalvariable'result'andmakeallneededchangestothecodeto workcorrectly. Step3:Replacetheif-statementwiththeconditionaloperator. Task3: Step1:Usethefollowingrecursivemethodtosearchanarrayofatleast10 elements. Step2:Modifythefunctionbyreplacingthearraybyusingpointers. Step3:Createadynamicarrayof20items,assignelementsvaluesrandomly,then asktheusertoinputthesearchnumber,andthencheckifthenumberisthere. int sum(int num){ int result; if (num == 1) result = 1; else result = num + sum(num-1); return result; } Lab12-BCS230,M.Alrajab 2 Task4: Step1:Runthefollowing programandcheckitsoutput. Step2:pass,noneedtodoit. Step3:counthowmanymoves arerequired. LAB12-ASSIGNMENT Problem:Apalindromeisastringthatreadsthesamebothforwardandbackward.Forexample,the string“madam”isapalindrome.Writeaprogramthatusesarecursivefunctiontocheckwhethera stringisapalindrome.Yourprogrammustcontainavalue-returningrecursivefunctionthatreturns trueifthestringisapalindromeandfalseotherwise.Donotuseanyglobalvariables,usethe appropriateparameters. Submissioninstructions: • DuedateisMay/01st@11:59pm. • SubmityoursourcecodeviaBlackboardonly. • Checkrubric. #include using namespace std; //tower of HANOI function implementation void TOH( int n, char Sour, char Aux, char Des){ if( n==1 ){ cout<"move disk=""><><" from=""><><" to=""><><"move disk=""><><" from=""><><" to=""><"enter no.="" of="" disks:";="" cin="">>n; //calling the TOH TOH(n,'A','B','C'); return 0; } int bSearch(const int a[], int lo, int hi, int X){ int m = (lo + hi) /2; if(lo > hi) return -1; // base if(a[m] == X) return m; // base if(a[m] > X) return bSearch(a,lo,m-1,X); else return bSearch(a,m+1,hi,X); }
Apr 25, 2020BCS230
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here