CSE – Computer Programming Homework #8 Solution

$30.00 $24.00

Part 1. [40 pts] Lets do some exercises to reinforce your recursion skills. You are asked to write a function that allows to do some useful operations on Hofstadter’s Q-Sequence. The formula of these sequences is shown below: ( ) = ( − ( − 1)) + ( − ( − 2)) (1) = (2)…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Part 1. [40 pts] Lets do some exercises to reinforce your recursion skills. You are asked to write a function that allows to do some useful operations on Hofstadter’s Q-Sequence. The formula of these sequences is shown below:

( ) = ( − ( − 1)) + ( − ( − 2))

(1) = (2) = 1

You must write four operational functions and one menu function to successfully do this part. Menu function should look like the following:

The function takes an empty, fixed-sized (define the size of the array as 500 and use it where you needed)

integer array that is used by the array operations in the menu:

  • Fill array: The option takes an integer number (n) from the user and fills the array with first n items of the Hofstadter’s Q-Sequence. The array items that out of the range (n) should be zero. The function prototype of this part is shown below:

void generate_hofstadters_sequence (int *arr, int n)

  • Find biggest number: The function finds the maximum valued item in the array recursively. The function prototype of this part is shown below:

int find_max (int arr[], int index, int max_value)

  • Calculate sum: The function calculates the sum of items in the array recursively. The function prototype of this part is shown below:

int sum_array (int arr[])

Page 1 of 3

CSE102 – Spring 2020 Homework #8

  • Calculate standard deviation: The function calculates the mean and the standard deviation of the array recursively. The function returns standard deviation by default and the mean value returns by reference.

double std_array (int arr[], double *mean, int n, int index)

  • Exit: Terminates the menu function. The menu should work until user select this option. Don’t forget to print the calculated/found values after the recursive functions done their jobs on option 2,3 and 4.

CSE – Computer Programming Homework #8 Solution
$30.00 $24.00