   Chapter 9.2, Problem 28ES ### 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

# In each of 24-28, determine how many times innermost loop will be iterated when thw algorithm sefrnent is implemented and run. (Assume that m , n , p , a , b , c and d are all positive integers.)Assume a ≤ b and c ≤ d for   i :=a   to   b for   j : = c   tod [ S t a t e m e n t   i n b o d y   o f   i n n e r l o o p . N o n e   c o n t a i n   b r a n c h i n g   s t a t e m e n t s   t h a t l e a d   o u t s i d e   t h e   l o o p . ] next   k next   j

To determine

The objective is to determine the number of times the innermost loop will be iterated when the algorithm segment is implemented and run.

Explanation

Given information:

Algorithm segment is implemented and run.

Concept used:

Assume that a,b,cand d are positive integers and aband cd.

Consider the algorithm below:

for i:=ato bfor j:=cto d........

next jnext i

The objective is to determine the number of times the innermost loop will be iterated when the algorithm segment is implemented and run.

Calculation:

It is given that aband cd

The numbers of integers from atob are ba+1.

The numbers of integers from ctod are dc+1.

The outer loop is iterated ba+1 times and each iteration of the outer loop, there are dc+1 of the inner loop.

Thus, by the rule of multiplication, the total number of iterations of the inner loop is,

(ba+1)(dc+1)

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