thanks

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

thanks

Post by answerhappygod »

thanks
Thanks 1
Thanks 1 (26.98 KiB) Viewed 23 times
Thanks 2
Thanks 2 (47.93 KiB) Viewed 23 times
Write the recursive function from the above recursive algorithm as follows: void reverse (int intArray[], int low, int high) ( // base case // general case //swap element at low and element at high int tempEle intArray[low]; intArray [low] = intArray [high]; intArray [high] = tempEle; reverse (intArray, low + 1, high - 1); } if (low >= high) return; Step 2 of 4 A else
The complete program is as follows: The following program demonstrates the functionality of the recursive function reverse(): #include <iostream> using namespace std; void reverse (int { if (low > high) return; else { } } int main() Step 3 of 4 A intArray[], int low, int high) // base case // general case //swap element at low and element at high int tempEle = intArray [low]; elements: for { intArray [low] = intArray [high]; intArray [high] = tempEle; reverse (intArray, low + 1, high - 1); int LENGTH= 10; int intArray[] = {1,2,3,4,5,6,7,8,9,10 1: //print the initial array elements cout << "Initial intArray elements: " << endl; for (int i = 0; i < LENGTH; i++) { cout << intArray << " "; } cout << endl; //reverse the elements between indices 2 and 4 reverse (intArray, 2, 4); //print the array elements after reversing elements between indices 2 and 4 cout << "After reversing elements between 2 and 4, intArray " << endl; (int i = 0; i < LENGTH; i++) cout << intArray << " "; } return 0;
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply