User talk:LARAIB comp

Recurrence Equation T(n) = 3T(n/4) + nlogn. Solution using Iteration method in Algorithm
T(n) = 3T(n/4) + nlogn - (1) now, plugging in 'n/4' value in the place of 'n' in eq (1), we get T(n/4) = 3T(n/4^2) + n/4 log(n/4) now, plug in T(n/4) in eq (1)

T(n) = 3 [3T(n/4^2) + n/4 log(n/4)] + nlogn = 3^2 T(n/4^2) + 3/4 n log(n/4) + nlogn now, iterativilly if we plug in the values T(n/4^2) then T(n/4^3) ... T(n/4^k) the equation will get expanded & we will get a patter

T(n) = 3^2[3T(n/4^3)+n/4^2log(n/4^2)] + 3/4 nlog(n/4) + nlogn = 3^3 T(n/4^3) + (3/4)^2 n log(n/4^2) + (3/4) nlog(n/4) + nlogn now, expanding the log value like log(a/b) = log a - log b    = 3^3 T(n/4^3) + (3/4)^2 n logn - (3/4)^2 nlog 4^2 + (3/4) nlogn -(3/4) nlog4 + nlogn = 3^3 T(n/4^3) + (3/4)^2 nlogn + (3/4) nlogn + nlogn - [(3/4)^2 nlog4^2 + (3/4) nlog4] = 3^4 T(n/4^4) + (3/4)^3 logn + (3/4)^2 nlogn + (3/4) nlogn + nlogn - [(3/4)^3 nlog4^3 + (3/4)^2 nlog4^2 + (3/4) nlog4 ] now, we have pattern = 3^k T(n/4^k)+...+ (3/4)^4 logn + (3/4)^3 logn + (3/4)^2 nlogn + (3/4) nlogn + nlogn - [(3/4)^k-1 nlog4^k-1+...+(3/4)^3 nlog4^3 + (3/4)^2 nlog4^2 + (3/4) nlog4 ]

now, let n/4^k = 1 n = 4^k taking log in base 4 both side logn = k plugin these values in above equation = 3^logn T(1)+ ... + (3/4)^4 logn + (3/4)^3 logn + (3/4)^2 nlogn + (3/4) nlogn + nlogn - [(3/4)^k-1 nlog4^k-1+...+(3/4)^3 nlog4^3 + (3/4)^2 nlog4^2 + (3/4) nlog4 ] - (2) as can be seen the following equation which is chopped off from eq.(2) ...+(3/4)^4 logn + (3/4)^3 logn + (3/4)^2 nlogn + (3/4) nlogn is in GP where a =   nlogn [first term] r = (3/4) [common ratio] we can ease the task if we approach the progression upto infinity then sum of infinite term of GP can be calculated as a / 1-r (when r < 1) ...+(3/4)^4 logn + (3/4)^3 logn + (3/4)^2 nlogn + (3/4) nlogn + nlogn = nlogn / 1 - (3/4) = 4nlogn

(3/4)^k-1 nlog4^k-1+...+(3/4)^3 nlog4^3 + (3/4)^2 nlog4^2 + (3/4) nlog4

again we ease the task by approaching the progression upto infinity which is chopped off from eq.(2) ...+(3/4)^3 nlog4^3 + (3/4)^2 nlog4^2 + (3/4) nlog4 log is in base 4, therefor we can simplify the equation let ...+(3/4)^3 3nlog4 + (3/4)^2 2nlog4 + (3/4) nlog4 = ...+(3/4)^3 3n + (3/4)^2 2n + (3/4) n = n[...+(3/4)^3 * 3 + (3/4)^2 * 2 + (3/4) * 1] & above equation is arithmatico-geomatric progression let S = ...+(3/4)^3 * 3 + (3/4)^2 * 2 + (3/4) * 1 (3/4)S = ...+(3/4)^4 * 3 + (3/4)^3 * 2 + (3/4)^2 * 1 S - (3/4)S = ...+(3/4)^3 + (3/4)^2 + (3/4) S/4 = (3/4)/ [1-(3/4)] S/4 = 3 S = 12

pugging in the values in eq. (2) T(n) = 3^logn + 4nlogn - 12n dominating part is 4nlogn therefor the complexity of equation is          Theta(nlogn)