Semester
Subject
Year
Tribhuwan University
2080
Bachelor Level / Third Year / Fifth Semester / Science
(Design and Analysis of Algorithms)
Full Marks: 60
Pass Marks: 24
Time: 3 Hours
Candidates are required to give their answers in their own words as for as practicable.
The figures in the margin indicate full marks.
Long Answers Questions
A recurrence relation is a mathematical equation that defines a function in terms of its value on smaller inputs, typically used to express the running time of recursive algorithms.
A recurrence relation describes the time complexity of a recursive algorithm by relating to of smaller values. It consists of:
Example: represents the recurrence for Merge Sort.
There are three main methods to solve recurrence relations:
Given:
Step A: Guess the solution
We guess that , i.e., for some constant .
Step B: Assume it holds for smaller inputs (Inductive Hypothesis)
Assume for all values less than .
Step C: Substitute into the recurrence
Substituting the hypothesis:
Step D: We need to show
From above,
This does not directly satisfy . So we strengthen our guess.
Step E: Strengthen the guess
Let us guess for constants and .
Assume
Substituting:
Step F: Verify the condition
Choose , then:
This satisfies our guess .
Step G: Verify the base case
For (base case), we need:
Choose and , both conditions are satisfied.
Since we have proven by induction that for and , we conclude:
The substitution method works by guessing the form of the solution and then proving it correct using mathematical induction. The key trick is to strengthen the hypothesis when the direct guess fails.
Short Answers Questions