Unit 3: Recursion and Advanced Techniques - Subjective Questions

CSE330 — Competitive Coding Approaches-Techniques • Practice Questions with Detailed Answers

20 questions

1

Define recursion. Explain the essential components of a recursive solution with a suitable example.

2

What is a base condition in recursion? Explain what can happen when it is missing or incorrectly specified.

3

Describe a systematic approach for solving a problem using recursion. Illustrate the approach by recursively finding the sum of an array.

4

Compare classic recursive approaches with modern techniques used to improve or replace recursion.

5

Distinguish between direct recursion and indirect recursion with examples. How can termination be verified in each case?

6

Differentiate between tail recursion and non-tail recursion. Convert a non-tail-recursive factorial function into a tail-recursive form.

7

Explain how memory is allocated during recursion. Use the recursive computation of factorial to describe stack-frame creation and removal.

8

Discuss the major advantages and disadvantages of recursive programming. State when an iterative solution may be preferable.

9

Define backtracking and explain the choose-explore-unchoose pattern. How does backtracking differ from ordinary exhaustive enumeration?

10

Derive a backtracking algorithm to generate all permutations of distinct elements. Explain its correctness and complexity.

11

How should a permutation-generating backtracking algorithm be modified when the input contains duplicate values?

12

Develop a recursive backtracking solution for the Combination Sum problem in which candidates are positive and may be reused. Explain the pruning strategy.

13

Explain how the N-Queens problem is solved using backtracking. Derive efficient safety checks for placing a queen.

14

Trace the recursive decision process for the 4-Queens problem and state all valid solutions using zero-based column positions.

15

Define a happy number and design an algorithm to find the smallest happy number strictly greater than a given integer .

16

Compare hash-set cycle detection and Floyd's cycle detection for determining whether a number is happy.

17

What is a sum string? Describe a recursive algorithm to determine whether a digit string satisfies the sum-string property.

18

Why should a sum-string algorithm use decimal-string addition instead of fixed-width integer conversion? Explain how string addition is performed.

19

Describe the water overflow problem for a pyramid of glasses and derive a recursive relation for the amount of water reaching each glass.

20

Design a row-by-row algorithm for the water overflow problem and explain why overflow must be propagated before capping a glass's stored amount.