   Chapter 11.5, Problem 12ES ### 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

# Exercises 12—15 refer to the following algorithm segment. For each positive integer n, let b n be the number of iterations of the while loop. while   ( n > 0 ) n : = n   d i v   3 end while 12. Trace the action of this algorithm segment on n when the initial value of n is 424.

To determine

Trace the action of this algorithm segment on n when the initial value of n is 424.

Explanation

Given information:

For each positive integer n, let bn be the number of iterations of the while loop. while ( n > 0)

n := n div 3

end whileCalculation:

We have:

while(n>0)    n:=n div 3end while

Initial assignments:

Initially, we set the value of n to 424.

We write this information down in a trace table.

 Iteration 0 n 424

FIRST ITERATION:

We next divide n = 424 by 3

3141 424 300 _ 124 120 _    4     3 _    1

We note that the quotient is 141 while the remainder is 1. We then assign the quotient of 141 to n.

n= quotient = 141

Writing this information down in the trace table, we obtain:

 Iteration 0 1 n 424 141

SECOND ITERATION:

We next divide n = 141 by 3

347 141 120 _   21    21 _     0

We note that the quotient is 47 while the remainder is 0. We then assign the quotient 47 to n.

n= quotient = 47

Writing this information down in the trace table, we obtain:

 Iteration 0 1 2 n 424 141 47

THIRD ITERATION:

We nest divide n = 47 by 3

315 47 30 _ 17 15 _  2

We note that the quotient is 15 while the remainder is 2

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