Question 1Asked in UGC NET Computer Science, December 2015 (Paper II & III, Selected Questions)
In general, in a recursive and non-recursive implementation of problem (program) :
ABoth time and space complexities are better in recursive than in non-recursive program
BBoth time and space complexities are better in non-recursive than in recursive program
CTime complexity is better in recursive version but space complexity is better in non-recursive version of the program
DSpace complexity is better in recursive version but time complexity is better in non-recursive version of the program
Show answerHide answer
Correct answer: (B) Both time and space complexities are better in non-recursive than in recursive program
Explanation
Recursion does not offer better space or time complexity; it only makes the program compact and simpler to write and understand than a non-recursive implementation. The non-recursive version avoids function-call overhead and stack space.
From UGC NET Computer Science PYQ, December 2015 (Paper II & III, Selected Questions)