ursive function can have only one base case. t or f?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

A recursive function can have only one base case.

t or f?

Expert Solution
Step 1

Recursion is a very important problem-solving approach that is an alternative to iteration remember that iterative solutions include looping construct.

Mathematics background:

 There is an accepted form of mathematical definition that uses concepts to define themselves. Such definitions are called inductive definitions. When carefully used, such definitions are very concise, very powerful, and very elegant.

Programming Approach of Recursion:

A problem solving / programming technique in which a method (function) can call itself in order to solve the problem. In the process, the problem is solved by reducing it to smaller versions of itself.

 

Step 2

Idea behind recursion : Each successive recursive call should bring you one step closer to a situation in which the problem can easily be solved. Each recursive definition has two separate parts -

  •  base case 
  • recursive case
  1. The easily solved situation or trivial condition is called the  base case. The base case is a simple case of the problem that we can answer directly; the base case does NOT use recursion. Each recursive algorithm must have at least one base case. Without at least one base case program may go to into the infinite recursion.
  2. The recursive case is the more complicated case of the problem that isn't easy to answer directly, but can be expressed elegantly with recursion. The general case is the place where the recursive calls are made --> written so that with repeated calls it reduces to the base case (or brings you closer to the base case).

Must eventually be reduced to a base case; if not --> infinite recursion. Must have at least one general case --> if not, no recursion!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education