Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction: The objective of this homework is to further enhance the understanding of the SELECT, min - max finding algorithm, and the application of SELECT

Introduction: The objective of this homework is to further enhance the understanding of the SELECT, min-max finding algorithm, and the application of SELECT algorithm in the Quick-Sort
Also, this is an individual submission, and no collaboration is expected.
1.[Optimal Max and Min Finding 15 Pts] In the max and min finding algorithms that we have discussed, we need n-1 comparisons. According to our textbook, however, at most 3*n/2 comparisons suffice to find both the minimum and maximum (pages 214-215):
Basic Strategy: Maintain the minimum and maximum of elements seen so far. Dont compare each element to the minimum and maximum separately. Process elements in pairs. Compare the elements of a pair to each other. Then compare the larger element to the maximum so far, and compare the smaller element to the minimum so far. This leads to only 3 comparisons for every 2 elements.
Setting up the initial values for the min and max depends on whether n is odd or even.
If n is even, compare the first two elements and assign the larger to max and the smaller to min. Then process the rest of the elements in pairs. If n is odd, set both min and max to the first element. Then process the rest of the elements in pairs.
a) Write the above description in algorithmic form. Follow the notations that we have discussed in class (see the minimum finding algorithm presented on page 214)
b) Show that your algorithm needs at most 3*n/2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago