Explore BrainMass

# Recursive Algorithm for Given Integer Array A

Not what you're looking for? Search our solutions OR ask your own Custom question.

This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

Implement two recursive algorithms to solve the following problems:

Problem 1: Implement a recursive algorithm to find the maximum element of given integer array A. Count the number of comparisons while finding the maximum element and print input size, maximum element, and number of comparisons.

Example: integer array A=[1,2,4,1,65,234,12,-10,-100]

Output of your program : Input size is : 9
Maximum element: 234
Number of compassion: 10 (This is just an example)

Problem 2: Implement a recursive algorithm to reverse given array of characters and print both arrays.

Example

Given array A=[a,c,v,f,e,r];

Output: Array A is acvfer
Reverse is refvca

https://brainmass.com/computer-science/arrays/implement-a-recursive-algorithm-to-find-the-maximum-element-of-given-integer-array-a-175072

#### Solution Preview

The recursive function is initially called as max(A, A.length) and count is set to 0 :

void max(Array [] A, int lastElmt){
if (lastElmt == ...

#### Solution Summary

This solution provides the recursive algorithm to find the maximum element of a given integer array A by counting the number of comparisons using print input size, maximum element and number of comparisons.

\$2.49