   Chapter 11.3, Problem 18ES ### 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.18. for i : = 1 to nfor j : = ⌊ ( i + 1 ) / 2 ⌋ to n x : = i ⋅ j next jnext i

To determine

(a)

Compute the actual number of the elementary operation by execution of algorithm.

Explanation

Given algorithm segments iteration of inner for-loop execute x:=i*j exactly done once .Let us determine the number of iteration of inner for-loop j goes up to (i+1)/2 to n ,which are n-(i+1)/2-1 possible value the for-loop have to iterate and for-loop I goes 1 to n.

First case when n is even then n+1 is odd thus no of iteration is n+n+(n1)+(n1)+.....(n+2)/2+(n+2)/2=1/4n2+5/2n

Second case when n is odd then n+1 is odd thus no of iteration is

n+n+(n1)+(n1)+

To determine

Use the theorem on polynomial order to find the order for the algorithm segments.

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