14 Lecture
CS301
Midterm & Final Term Short Notes
Recursive Calls
Recursive calls are a programming technique where a function calls itself within its own code. This allows for complex problems to be broken down into simpler, more manageable subproblems. Recursive calls use a stack to store information about e
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
- What is recursion? a. A process of dividing a problem into smaller subproblems b. A process of repeating a set of instructions c. A process of sorting data in ascending order d. None of the above
Answer: a
- What is the base case in recursion? a. The case where the function calls itself b. The case where the function returns a value without calling itself c. The case where the function uses a loop instead of recursion d. None of the above
Answer: b
- Which data structure is commonly used in recursion? a. Stack b. Queue c. Linked list d. Array
Answer: a
- What is the maximum number of recursive calls that can be made? a. 100 b. 1000 c. It depends on the available memory d. There is no limit
Answer: c
- Which of the following is a disadvantage of recursion? a. It is easy to understand and implement b. It may cause stack overflow errors c. It always results in better performance than iterative solutions d. None of the above
Answer: b
- Which of the following algorithms uses recursion? a. Quick sort b. Merge sort c. Bubble sort d. Selection sort
Answer: a and b
- Which of the following is true about recursive functions? a. They are always faster than iterative functions b. They require less memory than iterative functions c. They may be more readable and concise than iterative functions d. None of the above
Answer: c
- What is tail recursion? a. A type of recursion where the recursive call is the last operation performed by the function b. A type of recursion where the function calls itself multiple times c. A type of recursion where the function uses a loop instead of recursion d. None of the above
Answer: a
- What is the difference between direct and indirect recursion? a. Direct recursion occurs when a function calls itself, while indirect recursion occurs when two or more functions call each other. b. Direct recursion occurs when two or more functions call each other, while indirect recursion occurs when a function calls itself. c. Direct and indirect recursion are the same thing. d. None of the above
Answer: a
- Which of the following is an example of a recursive data structure? a. Linked list b. Stack c. Queue d. Array
Answer: a and b
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is recursion? Answer: Recursion is a programming technique where a function calls itself within its own code.
What is the base case in recursion? Answer: The base case is the case where the function returns a value without calling itself, stopping the recursive process.
What is the difference between direct and indirect recursion? Answer: Direct recursion occurs when a function calls itself, while indirect recursion occurs when two or more functions call each other.
What is tail recursion? Answer: Tail recursion is a type of recursion where the recursive call is the last operation performed by the function.
What is the maximum number of recursive calls that can be made? Answer: The maximum number of recursive calls that can be made depends on the available memory.
What is a stack overflow error? Answer: A stack overflow error occurs when the maximum stack size is exceeded due to too many recursive calls.
What are the advantages of recursion? Answer: Recursion can simplify complex problems by breaking them down into smaller subproblems, and can be more readable and concise than iterative solutions.
What are the disadvantages of recursion? Answer: Recursion may cause stack overflow errors and can be less efficient than iterative solutions.
What is the role of the base case in recursion? Answer: The base case provides a stopping condition for the recursive process.
What are some common algorithms that use recursion? Answer: Quick sort, merge sort, and binary search are common algorithms that use recursion.