Write a recursive function that has an argument that is an array of characters and two arguments that are bounds on array indexes. The function should reverse the order of those entries in the array whose indexes are between the two bounds. For example, if the array is a[0]

Respuesta :

Answer:

The function is as follows:

void revArray(char arr[], unsigned int low, unsigned int high)  {  

      if (low >= high){

        return;  }

  swap(arr[low], arr[high]);  

  revArray(arr, low + 1, high - 1);  }

Explanation:

This declares the function. It receives a char array and the lower and upper bounds to be reversed

void revArray(char arr[], unsigned int low, unsigned int high)  {  

This is the base case of the recursion (lower bound greater than or equal to the upper bound).

      if (low >= high){

        return;  }

This swaps alternate array elements

  swap(arr[low], arr[high]);  

This calls the function for another swap operation

  revArray(arr, low + 1, high - 1);  }

ACCESS MORE