Lab 11: Recursion
In this lab, we will write a program that uses recursion.
The execution of the finished program should look what is shown below (user input is shown in bold).
Please input the length of array:
5
Please input 5 integer numbers:
-23 0 45 456 -2
Examples ===============================
The array you input is:
-23 0 45 456 -2
Min value is: -23
Part 1 =================================
The sum of array is: 476
Max value is: 456
Part 2 =================================
Min value [-23]'s index is: 0
Max value [456]'s index is: 3
Extra Credit ===========================
The sorted array is:
-23 -2 0 45 456
The skeleton code is provided here: Lab11.cpp along with two examples, you need to implement the rest functions.
DO NOT change any code within 'main' function.
All functions must be implemented using recursion!
Part 1 (1 point):
int sum(int* array, int currentIndex, int arrayLength), recursively sum the elements within the array.
int maxValue(int* array, int currentIndex, int arrayLength), recursively find the maximum value within an array.
Part 2 (1 point):
int minValueIndex(int* array, int currentIndex, int arrayLength), recursively find the index of minimum value within the array.
int maxValueIndex(int* array, int currentIndex, int arrayLength), recursively find the index of maximum value within the array
Part 3 (Extra Credit, 1 point):
void sort(int* array, int currentIndex, int arrayLength), sort the array using recursion (ascending order).