Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

****Please use C++ language First, start by writing and testing the following fu

ID: 3822554 • Letter: #

Question

****Please use C++ language

First, start by writing and testing the following functions:

1. Write a recursive function to display the digits of an arbitrary integer in reverse order. That is, if called with the integer 2364, it would display 4 6 3 2.

2. Write a function that takes in a string and reverses it using a stack. Use an STL stack.

3. Write a recursive function that performs selection sort. Each recursive step should perform another pass on the array.

4. Write a recursive function that performs bubble sort. Each recursive step should perform another pass on the array.

Then, in your main body, test these programs.

- Read in a number from the user. Call your reverse function and output the integer in reverse.

- Prompt the user for a string, reverse it with your function and output it to the screen.

- Create an array of 10 random numbers, display it to the screen, then sort it with your recursive selection sort. Then output the results to the screen.

- Create a new array of 10 random numbers, display it to the screen, then sort it with your recursive bubble sort and output the results to the screen.

Explanation / Answer

HI, I have answered Q1 and Q3.

Please repost others in separate post.

Please let me know in case of any issue in Q1 and Q3.

/* Recursive function to reverse digits of num */

void reverseDigits(int number) {

    // base case
if (number < 10) {
cout<<number<<endl;
return;
}
// recursive case
else {
cout<<(number % 10)<<" ";
reverseDigits(number/10);
}
}

// Recursive Selection Sort:

void selectionSort(int[] array, int startIndex)
{
if ( startIndex >= array.length - 1 )
return;
int minIndex = startIndex;
for ( int index = startIndex + 1; index < array.length; index++ )
{
if (array[index] < array[minIndex] )
minIndex = index;
}
int temp = array[startIndex];
array[startIndex] = array[minIndex];
array[minIndex] = temp;
selectionSort(array, startIndex + 1);
}