MATH 302 Lecture 2

From Notes
Jump to navigation Jump to search

« previous | Wednesday, August 31, 2011 | next »


Binary insertion sort

Insertion sort using linear search requires O(n) comparisons (worst case)

Since the list is already sorted, we can use binary search to find where the element to be inserted should go. The function now becomes O(nlogn)

Asymptotic Analysis

limx|f(x)g(x)|={c0fΘ(g)0fO(g)fΩ(g)DNEtest fails


Domination (Big-O)

f(n)=7n2+22n is "asymptotically similar to" n2

A function f:+ is dominated by another function g if there exists positive constants k,c such that every integer n>k we have

|f(n)|c|g(n)|

The constants k,c are called "witnesses" to the dominating function g

We can say that f is not dominated by g if |f(x)|>C|g(x)|


General Theorem

A polynomial is dominated by its highest-degree term.

Given f(n)=aknk+ak1nk1++a0

Then f(n)nk


Example

Show 7n2+22nn2

n2>n for n>1,

Reversed Point of View (Big-Ω)

There are positive constants c,k so that |g(x)|C|f(x)| for x>k

Asymptotic Equivalence (Big-Θ)

"f and g are of the same order"


Example: Factorials

n!=k=1nk=1×2××nn×n××nnn!O(nn)