7.10 Programming Project #3:RecursionBackgroundRecursion is easy to learn but difficult to master. The definition of a recursive function isquite simple: its a function that must call itself in order to get its work done and thenstop through the use of a base case. While this definition is easy enough tounderstand, the ability to write good recursive code is a difficult skill to learn, and takesa lot of practice. There are two important things to keep in mind when designing afunction that uses recursion:1. Each time the function calls itself, that executing instance of the functionmaintains its own state, i.e. it contains its own unique set of local variables.2. When the function returns, it returns back to the point where it was called (justlike any other function) in the previous invocation of itself.ObjectiveCreate and test recursive functions.Project RequirementsCreate two recursive functions, hilo and rsort. While these functions could easily beimplemented iteratively, this project will assist you in mastering simple recursion. Youcan add your code for these functions to the file main.cpp below.hilo(int n)This function plays the high/low, binary search guessing game covered in this chapter.It calls GuessNumber with two changes: 1) reinterpret the guesses so that h meansthe guess was too high, and l means the guess was too low (this is the way mostpeople play the game), 2) modify GuessNumber to detect if any cheating has takenplace. This occurs when there is nothing left to guess.void rsort(int nums[ ], int nelems)This function sorts an array of integers by finding the minimum element, swapping itwith the first element, and then repeating the process on the rest of the array,recursively, until the entire array is sorted. It should call a helper function, voidsorthelp(int a[ ], int start, int n), which plays a role for sort similar towhat GuessNumber does for hilo.Here is a sample command-line execution: (the number is 30)Think of a number between 1 and 100I will try and guess it with your help.Is it 50 (l,y,h)? hIs it 25 (l,y,h)? lIs it 37 (l,y,h)? hIs it 31 (l,y,h)? hIs it 28 (l,y,h)? lIs it 29 (l,y,h)? lYour number is 30Sorted result:12345Here is an example where the user cheats near the end:Think of a number between 1 and 100I will try and guess it with your help.Is it 50 (l,y,h)? hIs it 25 (l,y,h)? lIs it 37 (l,y,h)? hIs it 31 (l,y,h)? hIs it 28 (l,y,h)? hIs it 26 (l,y,h)? hYou cheated!Sorted result:12345You will need a recursive helper function that takes three parameters: the array, thenumeric index of the first element in the array (0 on the first call), and the size of thearray at the moment (the number of elements in the first call). The stopping condition isan array of size 0.As always, you will need to enter all input at once in the project input window, forexample:hlhhll
CS-1410
[Solved] CS-1410-project 3-Recursion
$25
File Name: CS_1410_project_3_Recursion.zip
File Size: 254.34 KB
Only logged in customers who have purchased this product may leave a review.

![[Solved] CS-1410-project 3-Recursion](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CS-1410-project 2 -VectorsAndArrays](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.