Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a)There is a divide-and-conquer algorithm that uses less key constants to simultaneously determine the maximum and the minimum. This uses the following idea: 1. If

a)There is a divide-and-conquer algorithm that uses less key constants image text in transcribed to simultaneously determine the maximum and the minimum.

This uses the following idea: 1. If the set has only one element e, then this is at the same time the minimum and the maximum.

2. For a set with two elements (e1 and e2) one can find out with a comparison, which is the minimum and which is the maximum.

3. If the set has more than two elements, divide it recursively into two roughly equal subsets. As a result you get one smallest and one largest element (Min1, Max1, Min2, Max2). From this, 2 comparisons can be used to determine the total maximum and total minimum of the currently considered sublists.

Enter an algorithm in pseudocode that implements this idea.

b)In Java, implement a version of the algorithm from part a) that uses only positions as the transfer parameter, i. it should only be worked on a single list. This makes sense, especially against the background, that this is a search, so it should not be necessary to move elements or copy to find a record. Use a two-element int array with the maximum and minimum as the return type.

1-2 3n

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

6. What data will she need?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago