×
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 3.3 - Problem 12e
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 3.3 - Problem 12e

×

# Consider the following algorithm, which takes as input a

ISBN: 9780073383095 37

## Solution for problem 12E Chapter 3.3

Discrete Mathematics and Its Applications | 7th Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants

Discrete Mathematics and Its Applications | 7th Edition

4 5 1 293 Reviews
12
2
Problem 12E

Problem 12E

Consider the following algorithm, which takes as input a sequence of n integers a1, a2, …, an and produces as output a matrix M = {mij} where mij is the minimum term in the sequence of integers ai, ai+1, …, ai for j  i and mij = 0 otherwise.

initialize M so that mij = a, if j  i and mij = 0 otherwise

for i := 1 to n

for j := i + 1 to n

for k := i + 1 to j

mij := min(mij, ak)

return M = {mij}{mij is the minimum term of ai, ai+1, …, aj}

a)     Show that this algorithm uses O(n3) comparisons to compute the matrix M.

b)    Show that this algorithm uses Ω(n3) comparisons to compute the matrix M. Using this fact and part (a), conclude that the algorithms uses ⊝(n3) comparisons. [Hint: Only consider the cases where i ≤ n/4 and j ≥ 3n/4 in the two outer loops in the algorithm.]

Step-by-Step Solution:

Solution:

Step 1

In this problem we need to show that the given algorithm uses  comparisons to compute the matrix M.

Step 2 of 2

#### Related chapters

Unlock Textbook Solution