Answered step by step
Verified Expert Solution
Question
1 Approved Answer
REMINDER: - Every recursive function must have one or more base cases, - The general (recursive) case must eventually be reduced to a base case
REMINDER: - Every recursive function must have one or more base cases, - The general (recursive) case must eventually be reduced to a base case (terminating condition), - The base case stops the recursion, - Every recursive call has its own copy of parameters and the local variables [1], - A recursive function is a function that calls itself [5]. Let a be an array of integers. Present recursive algorithms and write their C implementations to compute: the maximum (minimum) element of the array, the sum (product) of the elements of the array, the average of the elements of the array HINT: Use functions having the following prototypes: name_of_the_function (int a[ ], int n); For example, function that computes maximum/minimum element in the array can be named as find_max ( ) / find_min(). The concept of recursion is fundamental in mathematics and computer science. The simple definition is that a recursive program in a programming language is one that calls itself (just as a recursive function in mathematics is one that is defined in terms of itself). ... All practical computations can be couched in a recursive framework. ... Many interesting algorithms are simply expressed with recursive programs, and many algorithm designers prefer to express methods recursively. Source: R.Sedgewick. Algorithms in C. Parts 1-4 (Fundamentals, Data Structures, Sorting, Searching), 3rd edition, Addison-Wesley Publ., 1998, 702 p. There are two approaches to writing repetitive algorithms: iteration and recursion. ... You should not use recursion if the answer to any of the following questions is "no": 1. Is the algorithm or data structure naturally suited to recursion? 2. Is the recursive solution shorter and more understandable? 3. Does the recursive solution run within acceptable time and space limits?. Source: R.F.Gilberg, B.A.Forouzan. Data Structures. A Pseudocode Approach with C, 2nd edition, Course Technology (Thomson), 2005, 720 p
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started