Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Suppose you are choosing between the following three algorithms: • Algorithm A solves problems by dividing them into five sub-problems of half the size, recursively solving each sub-problem, and then combining the solutions in linear time. •

Algorithm B solves problems of size n by recursively solving two sub-problems of size n-1and then combining the solutions in constant time. • Algorithm C solves problems of size n by dividing them into nine sub-problems of size n/3, recursively solving each sub-problem, and then combining the solutions in O(n2)time.

What are the running times of each of these algorithms (in big- O notation), and which would you choose?

Short Answer

Expert verified

Running time for each algorithm are:

  • Tn=Onlg5
  • Tn=O2n

Tn=On2logn

Step by step solution

01

Basic information about each algorithm

Algorithmic A solves issues by breaking these onto five half-size sub-problems and systematically answering each one.

Algorithm B repeatedly tackles two sub-problems in size n to solve these issues of size n .

Algorithm C divides issues of size n over nine sub-problems with size n/3 and solves every sub-problem iteratively.

02

Running time calculation

  1. Algorithm A will also be expressed as
    Tn=5Tn/2+n
    by use of the Master's theorem
    b=5a=2
    Thus, Tn=Onlg5
    1. Algorithm B will be expression as
    2. Tn=2Tn-1+c
      We're having multiple sub issues for every stage, like as 2,3,8,....
      So run time will be of order:

    localid="1659070651841" Tn=O2n

    1. For Algorithm C, calculation is based on question is given as above.
      Tn=9Tn/3+n2
      So,

    b=9a=3log39=2
    Which is equal to power of constant term
    so run time will be: Tn=On2logn

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free