Professional Documents
Culture Documents
If two algorithm for solving the problem where discovered and their times differed
by an order of magnitude, the one with the smaller order was generally regarded as
superior.
THE PURPOSE OF LOWER BOUND THEORY Is to find some techniques that have
been used to establish that a given alg is the most efficient possible.
1. Comparison trees.
1. Comparison Trees
a) Ordered Searching
• Each internal node in this tree represent a comparision between rc and A[i]
• There are three possible out come of this comparison. X < a[I]| x = a[I]|x > a[I]
• If the alg terminates following a left or right branch, then a[I] has been found s.t x
= a[I] & alg must declare the search unsuccessful.
Theorem 10.1
Let a[1:n], n> 1 contains n distinct elements, ordered that a[1] < . . . < A[n]. Let
Find (n) be the minimum number of comparisons needed, in the worst case, by any
comparison based alg. To recognize whether X∈ ∈∈ ∈ A [1:n]. The FIND (n)≥ ≥≥
≥log (n+1)
Proof
• Consider all possible comparison trees that model alg to solve the searching
problem
• FIND(n) – Lessthan the distance of the longest path from the root to a leaf node.
• There must be n internal nodes in all the these trees corresponding to the n
possible successful occurrences of x in A
• If all internal nodes of a binary tree are at levels less than or equal to K, them
there are at most 2k-1 internal nodes.
•Thus n < 2 k-1 and FIND (n) = k log (n+1). Hence Binary search is an optimal worst
– case algon for solving the searching problem.
B) Sorting
• Consider the case in which the n numbers a [1:n] to be sorted are distinct.
• Any comparison between a[I] and a[j] will result in one of two possibilities A [I]< A
[j] or A [j]> A [j]
• So comparison tree is a binary tree in which each internal node is labeled by the
pair I:j which represent the comparison of A[I], A[j]
• If A[I] is less than A[j] then the alg. Proceeds down the left branch of the tree,
otherwise it produces down the right branch.
• There are n! different possible permutation of n items, and any one of there might
legitimately be the only correct answer for sorting problem.
• Let T(n) be the minimum number of comparisons that are sufficient to sort n
items in the worst case. • Casing knowledge of Binary trees) if all internal nodes are
at levels less than k, then there are at most 2k external nodes (one more than no.
of external nodes.)
• Therefore, if we let k = T(n) N!≤ 2T(n) Since T(n) is an integer, we get the lower
bounds T(n)≥ log n!
http://www.scribd.com/doc/4074380/Computer-Algoritham-for-Chennai-
Univarsity-Unit5