   Chapter 11.5, Problem 15ES ### 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 15. Find an order for the algorithm segment.

To determine

Find an order for the algorithm segment.

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:

bn=number of iterations of the while-loop

Result previous exercise:

bn=1+log3n for all integers n1

The number of iterations of the algorithm is the number of iterations of the while-loop as the algorithm only contains the while-loop. Thus the number of iterations of the algorithm is bn=1+log3n when the input is n.

We will then prove that 1+log3n is Θ(log3n), which will implies that the order of the

algorithm is log3 n.

To proof:

log3n+1 is Θ(log3n)

PROOF:

By the definition of the floor function: |xx| for all real numbers x and when n3 then n23n.

|log3n+1||log3n+1|

=|log3n+log33|

=|log3(3n)|                                 logb(xy)=logbx+logby

|log3n2|                            x

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