Purchase Solution

Recursive Algorithm for Given Integer Array A

Not what you're looking for?

Ask Custom Question

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

Attachments
Purchase this Solution

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.

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 == ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

Basic Networking Questions

This quiz consists of some basic networking questions.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.