Prashnikaप्रश्निका
Code
About
‹ Back to the paper

Question 2

2 marks

Computer ScienceISC 2022 Computer Science - Specimen paper (Semester 2), Paper 1DifferentiateRecursion

Differentiate between the following.

Differentiate between direct recursion and indirect recursion.

Open in the Recursion visualiser

Answer

Answer

Direct recursion: a function calls itself directly, e.g. int f(int n) { ... f(n-1) ... }. Indirect recursion: a function calls another function, which in turn calls the first function back, e.g. A() calls B() and B() calls A().