   Chapter 11.3, Problem 7ES ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193

#### Solutions

Chapter
Section ### Discrete Mathematics With Applicat...

5th Edition
EPP + 1 other
ISBN: 9781337694193
Textbook Problem
1 views

# For each of the algorithm segments in 6—19, assume that n is a positive integer. (a) Compute the actual number of elementary operations (additions, subtractions, multiplications, divisions, and comparisons) that are performed when the algorithm segment is executed. For simplicity, however, count only comparisons that occur within if then statements; ignore those implied by for-next loops. (b) Use the theorem on polynomial orders to find an order for the algorithm segment.7. m a x : =   a [ 1 ] for i : = 2 to nif m a x < a [ i ] then m a x : = a [ i ] next i

To determine

(a)

The actual number of elementary operations performed.

Explanation

Given information:

We are given a snippet below.

Calculation:

The first elementary operation is assignment, so count is =1

Now for loop will execute n2+1 times which is equal to n1

Inside for loop there are two elementary operations one is comparison and other is assignment

In worst case both operations will be executed in every iteration

To determine

(b)

The polynomial order of the given algorithm.

### Still sussing out bartleby?

Check out a sample textbook solution.

See a sample solution

#### The Solution to Your Study Problems

Bartleby provides explanations to thousands of textbook problems written by our experts, many with advanced degrees!

Get Started 