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

Show that the worst-case complexity in terms of comparisons of an algorithm that finds the maximum and minimum ofn elements is at least 3n/2-2.

Short Answer

Expert verified

It is proved that Worst case complexity is at least 3n/2-2

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

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

01

Consider

Let us consider a list ofnelements. We need to determine the minimum and the

Maximum in the list, which could be any be thenelements. Thus there are2n

possibilities to obtain the actual minimum and maximum, while we need to eliminate

2n-2 of the possibilities to obtain the actual minimum and maximum.

Let us consider two elementsxand y. We will need to comparexand y(check if

x<y). when x<y , then we know that x is not the maximum andy is not the

Minimum. when xy then x is not the Minimum and y is not the maximum.

thus we note that we eliminate two possibilities per comparison.

02

Proof

There are at mostn/2 comparison between two elements that have not been

Compared previously (as we can divide the nelements in at most n/2 pairs),

which will thus remove at most 2n/2 comparison.

Since2n-2 possibilities need to be eliminated in total, we will then still need to

remove 2n-2-2n/2possibility .

However, we can only remove one such possibility per comparisons(as we compare

The possible maximums to remove one maximum per comparison and we compare

the possible minimums remove on minimum per comparison.

Thus there are then 2n-2-2n/2+n/2 comparison in total.

2n-2-2n/2+n/2 = 2n-2-n/2

= 2n-2+-n/2

= 2n+-n/2-2

= 2n-n/2-2

= 3n/2-2

Thus we require at most 3n/2-2comparison to find the maximum and minimum of a list of n elements, which implies that the worst case complexity is at least 3n/2-2.

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 Math 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