chapter

    Recursion and Backtracking Pyqs for Cmi M.sc. and Ph.d. Computer Science

    Solve 0+ Recursion and Backtracking previous year questions for CMI M.Sc. and Ph.D. Computer Science with answers and detailed solutions. Free sample question

    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Explore complete test series, official past papers, and chapter-wise study tools.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Recursion and Backtracking PYQs for CMI M.Sc. and Ph.D. Computer Science

    Solve 0+ Recursion and Backtracking previous year questions for CMI M.Sc. and Ph.D. Computer Science with answers and detailed solutions. Free sample questions below.

    Defining a problem by its smaller self

    Intuition

    Defining a problem by its smaller self

    You want to add the digits of 482 without using loops, so you isolate the last digit 2 and add it to the sum of the digits of 48.

    The problem it solves

    This physical act of peeling off one digit solves the whole problem. This analogy stops being valid when the problem cannot be decomposed into smaller instances of itself.

    The idea made exact

    The exact definition is a function that solves a problem by calling itself on a strictly smaller instance of the same problem. The exact version adds that this requires a stopping condition to prevent infinite recursion.

    valid when state strictly shrinks breaks when no base case exists

    The base case and the recursive step

    Derivation

    The base case and the recursive step

    Assume a positive integer .

    positive integer sum of digits
    1. Define the base case where the problem cannot be reduced further stop condition: If , the sum of digits is just .
    2. Define the recursive step which reduces the problem size isolate last digit: The last digit is and the remaining number is .
    3. Combine them add current digit to rest: The function returns .

    Apply this to . The first call returns . The second call returns . The third call hits the base case and returns 4. The final sum is .

    Result
    Check

    The manual addition also yields 14.

    More previous year questions (pyqs) in this unit