The Wayback Machine - https://web.archive.org/web/20240717181822/https://www.geeksforgeeks.org/difference-between-recursion-and-induction/
Open In App

Difference Between Recursion and Induction

Last Updated : 27 Dec, 2021
Improve
Suggest changes
Post a comment
Like Article
Like
Save
Share
Report

Recursion and induction belong to the branch of Mathematics, these terms are used interchangeably. But there are some differences between these terms. 

Recursion is a process in which a function gets repeated again and again until some base function is satisfied. It repeats and uses its previous values to form a sequence. The procedure applies a certain relation to the given function again and again until some base condition is met. It consists of two components: 

1) Base condition: In order to stop a recursive function, a condition is needed. This is known as a base condition. Base condition is very important. If the base condition is missing from the code then the function can enter into an infinite loop. 

2) Recursive step: It divides a big problem into small instances that are solved by the recursive function and later on recombined in the results.

Let a1, a2…… an, be a sequence. The recursive formula is given by:

an = an-1 + a1

Example: The definition of the Fibonacci series is a recursive one. It is often given by the relation:

F N = FN-1 + FN-2   
where F0 = 0

How to perform Recursion? 

Suppose the function given is

Tn = Tn-1  + C

We first use the given base condition. Let us denote base condition by T0, n= 2. we will find T1. C is the constant. 

Tn = Tn-1  + C //n=2
T2  = T2-1 + C
T1 = T1-1 + C
    = T0 + C + C // Base condition achieved, recursion terminates.

Induction

Induction is the branch of mathematics that is used to prove a result, or a formula, or a statement, or a theorem. It is used to establish the validity of a theorem or result. It has two working rules:

1) Base Step: It helps us to prove that the given statement is true for some initial value. 

2) Inductive Step: It states that if the theorem is true for the nth term, then the statement is true for (n+1)th term. 

Example: The assertion is that the nth Fibonacci number is at most 2n. 

How to Prove a statement using induction? 

Step 1: Prove or verify that the statement is true for n=1

Step 2: Assume that the statement is true for n=k

Step 3: Verify that the statement is true for n=k+1, then it can be concluded that the statement is true for n. 

Difference between Recursion and Induction:

S.No. Recursion  Induction
1. Recursion is the process in which a function is called again and again until some base condition is met.  Induction is the way of proving a mathematical statement. 
2. It is the way of defining in a repetitive manner. It is the way of proving.
3. It starts from nth term till the base case.  It starts from the initial till (n+1)th term. 
4.

It has two components:

  • Base condition
  • Recursive step.

It has two steps:

  • Base step
  • Inductive step
5. We backtrack at each step to replace the previous values with the answers using the function.  We just prove that the statement is true for n=1. Then we assume that n = k is true. Then we prove for n=k+1.
6. No assumptions are made.  The assumption is made for n= k
7. Recursive function is always called to find successive terms.  Here statements or theorems are proved and no terms are found. 
8. It can lead to infinity if no base condition is given.  There is no concept of infinity. 

Previous Article
Next Article

Similar Reads

Removing Direct and Indirect Left Recursion in a Grammar
Prerequisite - Classification of Context Free Grammars, Ambiguity and Parsers Introduction: Left recursion is a common problem that occurs in grammar during parsing in the syntax analysis part of compilation. It is important to remove left recursion from grammar because it can create an infinite loop, leading to errors and a significant decrease in
10 min read
How to solve time complexity Recurrence Relations using Recursion Tree method?
The Recursion Tree Method is a way of solving recurrence relations. In this method, a recurrence relation is converted into recursive trees. Each node represents the cost incurred at various levels of recursion. To find the total cost, costs of all levels are summed up. Steps to solve recurrence relation using recursion tree method: Draw a recursiv
4 min read
Difference between Difference Engine and Analytical Engine
Introduction: The development of computing technology has a rich history, with many inventions and innovations leading to the creation of the modern computer. Two such machines, the Difference Engine and Analytical Engine, were created by the English mathematician and inventor Charles Babbage in the 19th century. While these machines share some sim
7 min read
Difference between Voltage Drop and Potential Difference
Voltage Drop is defined as the decrease in the electric potential along the path of current that is flowing in an electric circuit. Voltage drop can be assigned at each point in the electric circuit that is proportional to the electrical elevation. The amount of energy delivered per second to any component in the circuit is equal to the voltage dro
4 min read
Difference Between Electric Potential and Potential Difference
The flow of electric charges is known as electricity, and it is responsible for producing electric current. An important word associated with electricity is electric potential. A potential difference is required to create the flow of electrons and hence, produce electricity. Before understanding the difference between electric potential and potenti
7 min read
Difference and Similarities between PHP and C
PHP is a server-side scripting language designed specifically for web development. It can be easily embedded in HTML files and HTML codes can also be written in a PHP file. The thing that differentiates PHP from a client-side language like HTML is, PHP codes are executed on the server whereas HTML codes are directly rendered on the browser. C is a
3 min read
Difference Between AND Gate and OR Gate
A logic gate is a simple switching circuit that determines whether an input pulse can pass through to the output in digital circuits. The building blocks of a digital circuit are logic gates, which execute numerous logical operations that are required by any digital circuit. These can take two or more inputs but produce only one output. The mix of
3 min read
Difference between Stop and Wait, GoBackN and Selective Repeat
Reliable data transfers are one of the primary concerns in computer networking. This service department lies in the hands of TCP. Their major flow control protocols - Stop and Wait, Go Back N, and Selective Repeat. Stop and Wait ARQ - The sender sends the packet and waits for the acknowledgement of the packet. Once the acknowledgement reaches the s
2 min read
Difference between Stop and Wait protocol and Sliding Window protocol
Introduction: Both Stop and Wait protocol and Sliding Window protocol are the techniques to the solution of flow control handling. The main difference between Stop-and-wait protocol and Sliding window protocol is that in Stop-and-Wait Protocol, the sender sends one frame and wait for acknowledgement from the receiver whereas in sliding window proto
4 min read
Similarities and Difference between Java and C++
Nowadays Java and C++ programming languages are vastly used in competitive coding. Due to some awesome features, these two programming languages are widely used in industries as well as comepetitive programming . C++ is a widely popular language among coders for its efficiency, high speed, and dynamic memory utilization. Java is widely used in the
6 min read
three90RightbarBannerImg