Analysis of the Brute force Maxima Algorithm - Design and Analysis - Study Notes, Study notes of Digital Systems Design

Analysis of the brute force maxima algorithm, Arithmetic series, Quadratic series, Geometric series, Harmonic series, Analysis A Harder Example, 2 Dimension Maxima Revisited are the key points in this study notes.

Typology: Study notes

2011/2012

Uploaded on 11/03/2012

ankitay
ankitay 🇮🇳

4.4

(50)

106 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture No. 4
1.10.1 Analysis of the brute-force maxima algorithm.
Assume that the input size is n, and for the running time we will count the number of time that any element
of P is accessed. Clearly we go through the outer loop n times, and for each time through this loop, we go
through the inner loop n times as well. The condition in the if-statement makes four accesses to P. The
output statement makes two accesses for each point that is output. In the worst case every point is maximal
(can you see how to generate such an example?) so these two access are made for each time through the
outer loop.
Thus we might express the worst-case running time as a pair of nested summations, one for the i-loop and
the other for the j-loop:
For small values of n, any algorithm is fast enough. What happens when n gets large? Running time does
become an issue. When n is large, n2 term will be much larger than the n term and will dominate the
running time.
We will say that the worst-case running time is Θ(n2). This is called the asymptotic growth rate of the
function. We will discuss this Θ-notation more formally later.
The analysis involved computing a summation. Summation should be familiar but let us review a bit here.
Given a finite sequence of values a1, a2, . . . , an, their sum
a1 + a2 + . . . + an is expressed in summation notation as
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Analysis of the Brute force Maxima Algorithm - Design and Analysis - Study Notes and more Study notes Digital Systems Design in PDF only on Docsity!

Lecture No. 4

1.10.1 Analysis of the brute-force maxima algorithm.

Assume that the input size is n, and for the running time we will count the number of time that any element of P is accessed. Clearly we go through the outer loop n times, and for each time through this loop, we go through the inner loop n times as well. The condition in the if-statement makes four accesses to P. The output statement makes two accesses for each point that is output. In the worst case every point is maximal (can you see how to generate such an example?) so these two access are made for each time through the outer loop.

Thus we might express the worst-case running time as a pair of nested summations, one for the i-loop and the other for the j-loop:

For small values of n, any algorithm is fast enough. What happens when n gets large? Running time does become an issue. When n is large, n^2 term will be much larger than the n term and will dominate the running time.

We will say that the worst-case running time is Θ(n^2 ). This is called the asymptotic growth rate of the function. We will discuss this Θ-notation more formally later. The analysis involved computing a summation. Summation should be familiar but let us review a bit here.

Given a finite sequence of values a 1 , a 2 ,... , a n , their sum

a 1 + a 2 +... + a n is expressed in summation notation as

If n = 0, then the sum is additive identity, 0. Some facts about summation: If c is a constant

and

Some important summations that should be committed to memory. Arithmetic series

Quadratic series

Geometric series

If 0 < x < 1 then this is Θ (1), and if x > 1, then this is Θ (xn). Harmonic series For n ≥ 0

Its running time is determined by i. LetM() be the time spent in the for loop:

Finally the outer-most for loop.

Let T() be running time of the entire algorithm:

1.11.1 2-dimension Maxima Revisited

Recall the 2-d maxima problem: Let a point p in 2-dimensional space be given by its integer coordinates, p = (p.x, p.y). A point p is said to dominated by point q if p.x ≤ q.x and p.y ≤ q.y. Given a set of n points, P = {p 1 , p 2 ,... , pn } in 2-space a point is said to be maximal if it is not dominated by any other point in P. The problem is to output all the maximal points of P. We introduced a brute-force algorithm that ran in Θ (n 2 ) time. It operated by comparing all pairs of points. Is there an approach that is significantly better?

The problem with the brute-force algorithm is that it uses no intelligence in pruning out decisions. For example, once we know that a point pi is dominated by another point p j , we do not need to use pi for eliminating other points. This follows from the fact that dominance relation is transitive. If p j dominates p i and p i dominates p h then p j also dominates p h ; p i is not needed.