Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Dear Chegg: I want to you to check and correct my pseudocode, and my pseudo code is down below Design an algorithm to using recursion

Dear Chegg:

I want to you to check and correct my pseudocode, and my pseudo code is down below

Design an algorithm to using recursion to find the total, highest number, lowest number of an array whose elements are numbers.

Requirements:

1. The algorithm should have a main module and 3 functions

2. a recursive function to find and return the total of an array. The array will be passed to the function as argument

3. a recursive function to find and return the highest value in an array. The array will be passed to the function as argument

4. a recursive function to find and return the lowest value in an array. The array will be passed to the function as argument

5. In the main module, define an array with integers. Then call the three functions by passing the array to the functions as argument. The program will then display the result

6. Pseudocode or flowchart

Pseudocode:

Module main ()

Declare array, size, sumNum, maximum

Display Enter the value of size of array:

Input size

For counter= 0 to size -1

Display Enter the value of array element#

Input array[counter]

End for

Function for Sum of Array

Set sumNum= sumArray(array, size)

Display sum of array of number is

Display sumNum

Call End Module//end of module

Function Integer sumArray (integer array[], integer size)

If (size==1)

Return array[0]

Else

Return array[size-1]+sumArray(array,size-1)

End if

End function

Function for Highest value

Set maxNum= maxArray(array,size,maxNum)

Display Max number is

Display maxNum

Call end Module//end of module

Function integer maxArray (integer array [], integer size, Integer max)

If size ==0

Return max;

Else

If max

Max=array[size-1]

End if

Return maxArray (array, size-1, max);

End if

End function

function for Lowest value

Set minNum= mainArray(array,size,minNum)

Display Min number is

Display minNum

Call end Module//end of module

Function integer minArray (integer array [], integer size, Integer min)

If size ==0

Return min;

Else

If min

Min=array[size-1]

End if

Return minArray (array, size-1, min);

End if

End function

Main module()

Int main()

Int Array[]= {1,2,3,4,5,6,7,8,9,10};//Define an array

Int N= size of (Array)/size of (Array[0]);//Calculate the size of the array(number of elements

Display Sum of elements of array, + sumNum

Display Highest Value int the array, +maxNum

Display Lowest Value int the array, + minNum

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions