Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ please COMP 53: Algorithm Analysis, part 2 Instructions: in this lab, we are going to revicw recursion. - Get into groups of at most
c++ please
COMP 53: Algorithm Analysis, part 2 Instructions: in this lab, we are going to revicw recursion. - Get into groups of at most two people to accomplish this lah. - At the top of your source code files list the group members as a comment. - Each member of the group must individually submit the lab in Canvas. - This lab includes 24 points in aggregate. The details are given in the following. 1 main.cpp In ma in. cpp do the following step by step: 1. Globally define array a [] of integers consisting of values: 2,8,1,7,3 in order. 2. Globally define array b [] of integers, without initial values. 3. Define recursive function void print.Array (int a[1, int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It prints the elements in the standard output. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 4. Define recursive function void print:ReverseArray (int. a[], int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It prints the elements in the standard output in the reverse format. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 5. Define recursive function void reverseArray (int a[], int start, int end) that receives an array of integers along with an start index, and and end index. It reverses the elements in the input array that are indexed between start. and end. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 6. Define recursive function int sumArray (int a [], int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It returns the summation of all numbers in the array. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 7. Define recursive function int productArray (int a[], int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It returns the production of all numbers in the array. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 8. Define recursive function int minArray (int a [], int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It returns the minimum of all numbers in the array. Do not use any loops, and rely on recursion to traverse the array ( 2 points). 9. Define recursive function int. maxArray (int a[1, int size, int index) that receives an array of integers along with its size, and index (an integer) of the current element. It returns the maximum of all numbers in the array. Do not use any loops, and rely on recursion to traverse the array (2 points). In main () function do the following step by step, using the functions defined above: (a) Print out the contents of array a [] in order ( I points). (b) Print out the contents of array a Ll in reverse (do not reverse the array) (I points). (c) Print out the contents of array a \lfloor] after reversing it ( 1 points). (d) Print out the summation of elements of array a [ floor (I points). (c) Print out the product of elements of array a I] (I points). (f) Copy array a \lfloor floor to b] and print out b] 's elements (I points). (g) Print out the minimum element of array a [l (1 points). (h) Print out the maximum element of array a [] (1 points). (i) All of the recursive functions have the similar recurrence runtime relation. Comment the recurrence relation in main () in terms of big-O (I points). (j) What is the runtime complexity according to the recurrence relation? Comment it in main () (I points). The output of the program may look like the following: Array a[l content in order: Array a [] content in reverse: 3%182 Reversing a [ floor : 37182 Summation of clements in a ] : 21 Product of clements in a ll: 336 Copying all to b[J: 37182 Minimum element in a[l: 1 Maximum element in a[l: 8Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started