CBSE Class 12 Computer Science Question 71 of 101

Functions — Question 39

Back to all questions
39
Question

Question 35

Why are recursive functions considered slower than their iterative counterparts?

Answer

When a loop is executed repeatedly, it uses the same memory locations for variables and repeats the same unit of code. On the other hand, recursion allocates fresh memory space for each recursive call, avoiding the repetition of code and the reuse of memory locations for variables. Due to stack manipulation and the allocation of additional memory space, recursive functions often run slower and consume more memory than their iterative counterparts.