×
Log in to StudySoup
Get Full Access to Math - Textbook Survival Guide
Join StudySoup for FREE
Get Full Access to Math - Textbook Survival Guide

a) Describe in detail (and in English) the steps of an

Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen ISBN: 9780073383095 37

Solution for problem 6E Chapter 3.SE

Discrete Mathematics and Its Applications | 7th Edition

  • Textbook Solutions
  • 2901 Step-by-step solutions solved by professors and subject experts
  • Get 24/7 help from StudySoup virtual teaching assistants
Discrete Mathematics and Its Applications | 7th Edition | ISBN: 9780073383095 | Authors: Kenneth Rosen

Discrete Mathematics and Its Applications | 7th Edition

4 5 1 282 Reviews
19
4
Problem 6E

a) Describe in detail (and in English) the steps of an algorithm that finds the maximum and minimum of a sequence of n elements by examining pairs of successive elements, keeping track of a temporary maximum and a temporary minimum. If n is odd both the temporary maximum and temporary minimum should initially equal the first term, and if n is even, the temporary minimum and temporary maximum should be found by comparing the initial two elements. The temporary maximum and temporary minimum should be updated by comparing them with the maximum and minimum of the pair of elements being examined.________________b) Express the algorithm described in part (a) in pseudocode.________________c) How many comparisons of elements of the sequence arc carried out by this algorithm? (Do not count comparisons used to determine whether the end of the sequence has been reached.) How does this compare to the number of comparisons used by the algorithm in Exercise 5?

Step-by-Step Solution:

Solution:Step 1:a). We have to describe an algorithm that finds the maximum and minimum of a sequence of n elements by examining pairs of successive elements, keeping track of a temporary maximum and a temporary minimum.Step 2:The way to deal with the calculation is very like the conventional strategy for finding the maximum and minimum elements. Here, if n is odd, both the brief temporary maximum and temporary minimum ought to at first equivalent the primary term, and if n is even, the temporary minimum and temporary maximum ought to be found by looking at the underlying two components. The brief temporary maximum and temporary minimum ought to be refreshed by contrasting them and the maximum and minimum of the match of components being analyzed. Just a single loop is adequate to locate the maximum and minimum values.Step 3:b). We have to express the algorithm in the form of a pseudocode.Algorithm: Finding the maximum and minimum elementsProcedure max-min(a1,a2,a3 ………..an: natural numbers)If n = odd thenMax:= a1Min: = a1Else Max: = max(a1,a2)min:= min(a1,a2)i:=3While i If max < max(a1,a2)If min >min(a1,a2)i:=i+2Return min, max{min is the smallest element ,m is the largest}Step 5:c). Next, we need to appraise the quantity of examinations utilized as a part of the above calculation. We see that there is just a solitary loop that keeps running for [n/2] time ventures, since just a single of the two components in a couple is thought about. This is unmistakably a large portion of the quantity of correlations utilized by the standard calculation for finding the maximum and minimum values.

Step 4 of 5

Chapter 3.SE, Problem 6E is Solved
Step 5 of 5

Textbook: Discrete Mathematics and Its Applications
Edition: 7
Author: Kenneth Rosen
ISBN: 9780073383095

This textbook survival guide was created for the textbook: Discrete Mathematics and Its Applications, edition: 7. Since the solution to 6E from 3.SE chapter was answered, more than 349 students have viewed the full step-by-step answer. Discrete Mathematics and Its Applications was written by and is associated to the ISBN: 9780073383095. The full step-by-step solution to problem: 6E from chapter: 3.SE was answered by , our top Math solution expert on 06/21/17, 07:45AM. The answer to “a) Describe in detail (and in English) the steps of an algorithm that finds the maximum and minimum of a sequence of n elements by examining pairs of successive elements, keeping track of a temporary maximum and a temporary minimum. If n is odd both the temporary maximum and temporary minimum should initially equal the first term, and if n is even, the temporary minimum and temporary maximum should be found by comparing the initial two elements. The temporary maximum and temporary minimum should be updated by comparing them with the maximum and minimum of the pair of elements being examined.________________b) Express the algorithm described in part (a) in pseudocode.________________c) How many comparisons of elements of the sequence arc carried out by this algorithm? (Do not count comparisons used to determine whether the end of the sequence has been reached.) How does this compare to the number of comparisons used by the algorithm in Exercise 5?” is broken down into a number of easy to follow steps, and 156 words. This full solution covers the following key subjects: temporary, maximum, minimum, elements, Algorithm. This expansive textbook survival guide covers 101 chapters, and 4221 solutions.

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

a) Describe in detail (and in English) the steps of an

×
Log in to StudySoup
Get Full Access to Math - Textbook Survival Guide
Join StudySoup for FREE
Get Full Access to Math - Textbook Survival Guide
×
Reset your password