Question

Understand the Master’s Theorem, be able to use it in algorithm analysis. For instance,if the sor...

Understand the Master’s Theorem, be able to use it in algorithm analysis. For instance,if the sorting algorithm split the array into 5 parts instead of two parts, how do you use the Master’s Theorem for the complexity analysis?

(extra info by professor: In what cases you need to have b with different a? You usually can choose a=b. However, for f(n), it could be different. )

I think the question wants calculating/proving the time complexity mathematically if the problem is divided into 5 sub problems)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Master Theorem is used to determine running time of algorithms (divide and conquer algorithms) in terms of asymptotic notations.
Consider a problem that be solved using recursion

function f(input x size n)
if(n > k)
solve x directly and return 
else
divide x into a sub-problems of size n/b
call f recursively to solve each sub-problem
Combine the results of all sub-problems

The above algorithm divides the problem into a subproblems, each of size n/b and solve them recursively to compute the problem and the extra work done for problem is given by f(n), i.e., the time to create the subproblems and combine their results in the above procedure.

So, according to master theorem the runtime of the above algorithm can be expressed as:

where n = size of the problem
a = number of subproblems in the recursion and a >= 1
n/b = size of each subproblem
f(n) = cost of work done outside the recursive calls like dividing into subproblems and cost of combining them to get the solution.

Not all recurrence relations can be solved with the use of the master theorem i.e. if

  • T(n) is not monotone, ex: T(n) = sin n
  • f(n) is not a polynomial, ex: T(n) = 2T(n/2) + 2n

This theorem is an advance version of master theorem that can be used to determine running time of divide and conquer algorithms if the recurrence is of the following form :-

T(n) aT (n/b)+ e(n logPn)

where n = size of the problem
a = number of subproblems in the recursion and a >= 1
n/b = size of each subproblem
b > 1, k >= 0 and p is a real number.

Then,

  1. if a > bk, then T(n) = θ(nlogba)
  2. if a = bk, then
    (a) if p > -1, then T(n) = θ(nlogba logp+1n)
    (b) if p = -1, then T(n) = θ(nlogba loglogn)
    (c) if p < -1, then T(n) = θ(nlogba)
  3. if a < bk, then
    (a) if p >= 0, then T(n) = θ(nk logpn)
    (b) if p < 0, then T(n) = θ(nk)

Time Complexity Analysis –

  • Example-1: Binary Search – T(n) = T(n/2) + O(1)
    a = 1, b = 2, k = 0 and p = 0
    bk = 1. So, a = bk and p > -1 [Case 2.(a)]
    T(n) = θ(nlogba logp+1n)
    T(n) = θ(logn)
  • Example-2: Merge Sort – T(n) = 2T(n/2) + O(n)
    a = 2, b = 2, k = 1, p = 0
    bk = 1. So, a = bk and p > -1 [Case 2.(a)]
    T(n) = θ(nlogba logp+1n)
    T(n) = θ(nlogn)
  • Example-3: T(n) = 3T(n/2) + n2
    a = 3, b = 2, k = 2, p = 0
    bk = 4. So, a < bk and p = 0 [Case 3.(a)]
    T(n) = θ(nk logpn)
    T(n) = θ(n2)
  • Example-4: T(n) = 3T(n/2) + log2n
    a = 3, b = 2, k = 0, p = 2
    bk = 1. So, a > bk [Case 1]
    T(n) = θ(nlogba )
    T(n) = θ(nlog23)
  • Example-5: T(n) = 2T(n/2) + nlog2n
    a = 2, b = 2, k = 1, p = 2
    bk = 1. So, a = bk [Case 2.(a)]
    T(n) = θ(nlogbalogp+1n )
    T(n) = θ(nlog22log3n)
    T(n) = θ(nlog3n)
Add a comment
Know the answer?
Add Answer to:
Understand the Master’s Theorem, be able to use it in algorithm analysis. For instance,if the sor...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that...

    What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Read “Instituionalizing our Demise: America vs Multiculturalism” by Roger Kimball on pg 268 and “Reinventing America”...

    Read “Instituionalizing our Demise: America vs Multiculturalism” by Roger Kimball on pg 268 and “Reinventing America” Call for a new national indentity” by Elizabeth Martinez on pg 275. Create a double entry notebook for each reading selection It should be atleast five observation and responses. wric 268 PART 2 essay pro. exactly how and why their authors disagree. Instead of with parties in conflict as mediators do, you will nt of view designed to appeal to both sides, mediatn posing...

  • A. Issues [1] In addition to damages for one year's notice period, can a trial judge...

    A. Issues [1] In addition to damages for one year's notice period, can a trial judge award significant damages for the mere fact of an employee's dismissal, or for the stigma that that dismissal brings? Or for the employer thereafter competing with the ex-employee for the clients, before the ex-employee has got a new job? B. Basic Facts [2] This is an appeal from 2009 ABQB 591 (CanLII), 473 A.R. 254. [3] Usually a judgment recites facts before law. But...

  • SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the...

    SYNOPSIS The product manager for coffee development at Kraft Canada must decide whether to introduce the company's new line of single-serve coffee pods or to await results from the product's launch in the United States. Key strategic decisions include choosing the target market to focus on and determining the value proposition to emphasize. Important questions are also raised in regard to how the new product should be branded, the flavors to offer, whether Kraft should use traditional distribution channels or...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • I have this case study to solve. i want to ask which type of case study...

    I have this case study to solve. i want to ask which type of case study in this like problem, evaluation or decision? if its decision then what are the criterias and all? Stardust Petroleum Sendirian Berhad: how to inculcate the pro-active safety culture? Farzana Quoquab, Nomahaza Mahadi, Taram Satiraksa Wan Abdullah and Jihad Mohammad Coming together is a beginning; keeping together is progress; working together is success. - Henry Ford The beginning Stardust was established in 2013 as a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT