The document discusses the Master's theorem method for solving recurrence relations. It presents the general form of recurrence relations that can be solved using this method as T(n) = aT(n/b) + θ(nklogpn). It then outlines the three cases of the Master's theorem based on comparing the values of a and bk. Several examples are provided to demonstrate how to set up and solve different types of recurrence relations using the Master's theorem method.
The document discusses the Master's theorem method for solving recurrence relations. It presents the general form of recurrence relations that can be solved using this method as T(n) = aT(n/b) + θ(nklogpn). It then outlines the three cases of the Master's theorem based on comparing the values of a and bk. Several examples are provided to demonstrate how to set up and solve different types of recurrence relations using the Master's theorem method.
The document discusses the Master's theorem method for solving recurrence relations. It presents the general form of recurrence relations that can be solved using this method as T(n) = aT(n/b) + θ(nklogpn). It then outlines the three cases of the Master's theorem based on comparing the values of a and bk. Several examples are provided to demonstrate how to set up and solve different types of recurrence relations using the Master's theorem method.
Analysis of Algorithm Master Theorem Method Master theorem solves recurrence relations of the form-
Here, a >= 1, b > 1, k >= 0 and p is a real
number. Master Theorem Cases To solve recurrence relations using Master’s theorem, we compare a with bk.
Then, we follow the following cases-
Example
Solve the following recurrence relation using Master’s theorem- T(n) = 3T(n/2) + n2
Solution-
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn). Then, we have- a=3 b=2 k=2 p=0
Now, a = 3 and bk = 22 = 4. Clearly, a < bk. So, we follow case-03.
Since p = 0, so we have- T(n) = θ (nklogpn) T(n) = θ (n2log0n)
T(n) = θ (n2)
Example 2 Solve the following recurrence relation using Master’s theorem- T(n) = 2T(n/2) + nlogn
Solution-
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn). Then, we have- a=2 b=2 k=1 p=1
Now, a = 2 and bk = 21 = 2. Clearly, a = bk. So, we follow case-02.
Since p = 1, so we have- T(n) = θ (nlogba.logp+1n) T(n) = θ (nlog22.log1+1n)
Thus, T(n) = θ (nlog2n) Example 3 Solve the following recurrence relation using Master’s theorem- T(n) = 2T(n/4) + n0.51
Solution-
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn). Then, we have- a=2 b=4 k = 0.51 p=0
Now, a = 2 and bk = 40.51 = 2.0279. Clearly, a < bk. So, we follow case-03.
Since p = 0, so we have- T(n) = θ (nklogpn) T(n) = θ (n0.51log0n)
Thus, T(n) = θ (n0.51) Example 4 Solve the following recurrence relation using Master’s theorem-
T(n) = √2T(n/2) + logn
Solution-
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn). Then, we have- a = √2 b=2 k=0 p=1
Now, a = √2 = 1.414 and bk = 20 = 1. Clearly, a > bk. So, we follow case-01.
So, we have- T(n) = θ (nlogba) T(n) = θ (nlog2√2) T(n) = θ (n1/2)
Thus,
T(n) = θ (√n)
Example Solve the following recurrence relation using Master’s theorem- T(n) = 8T(n/4) – n2logn
Solution-
The given recurrence relation does not correspond to the general form of Master’s theorem. So, it can not be solved using Master’s theorem. Example 7 Solve the following recurrence relation using Master’s theorem- T(n) = 3T(n/3) + n/2
Solution-
We write the given recurrence relation as T(n) = 3T(n/3) + n. This is because in the general form, we have θ for function f(n) which hides constants in it. Now, we can easily apply Master’s theorem.
We compare the given recurrence relation with T(n) = aT(n/b) + θ (nklogpn). Then, we have- a=3 b=3 k=1 p=0
Now, a = 3 and bk = 31 = 3. Clearly, a = bk. So, we follow case-02.
Since p = 0, so we have- T(n) = θ (nlogba.logp+1n) T(n) = θ (nlog33.log0+1n) T(n) = θ (n1.log1n)