Finiteness - Data Structures and OO Development - Handout | CS 2606, Study notes of Data Structures and Algorithms

Material Type: Notes; Professor: McQuain; Class: Data Structs & OO Development; Subject: Computer Science; University: Virginia Polytechnic Institute And State University; Term: Fall 2008;

Typology: Study notes

Pre 2010

Uploaded on 10/13/2008

trogdor
trogdor ๐Ÿ‡บ๐Ÿ‡ธ

11 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Finiteness: Algorithm must complete after a finite number of instructions have been executed
absence of Ambiguity: Each step must be clearly defines, having only one interpretation
definition of Sequence: Each step must have a unique defined preceding and succeeding step. The first step (start step) and last step
(halt step) must be clearly noted.
input/Output: Number and types of required inputs and results must be specified.
Feasibility: It must be possible to perform each instruction
logn, n, nlogn, n^2, n^3, 2^n
Big-O: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is O(g(n)) provided that there are constants C
> 0 and N > 0 such that for all n > N, f(n) <= Cg(n).
-expresses and upper bound
-Theorems: 1.) K is O(1)
2.) A polynomial is O(the term containing the highest power of n)
3.) K*f(n) is O(f(n)) (i.e. you can drop constants)
4.) If f(n) is O(g(n)) and g(n) is O(h(n)) then f(n) is O(h(n)) [transitivity]
5.) K, logb(n), n, nlogb(n), n^2, n^higher power, 2^n, 3^n, larger constants^n, n!, n^n
6.) f(n) is O(the dominant term of f(n))
7.) for any base b, logb(n) is O(log(n))
Big-Omega: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is
๎‚ถ๎‚žg๎‚žn๎‚Ÿ๎‚Ÿ
provided that there are
constants C > 0 and N > 0 such that for all n > N, f(n) >= Cg(n).
-expresses a lower bound
Big-Theta: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is
๎‚ฎ๎‚ž g๎‚žn๎‚Ÿ๎‚Ÿ
provided that f(n) is
O(g(n)) and also that f(n) is
๎‚ถ๎‚žg๎‚žn๎‚Ÿ๎‚Ÿ
.
-Theroems:
8.) f(n) is
๎‚ฎ๎‚ž g๎‚žn๎‚Ÿ๎‚Ÿ
if
lim
n๎‚Œโˆž
f๎‚žn๎‚Ÿ
g๎‚žn๎‚Ÿ=c , where 0๎‚„c๎‚„ โˆž
1. corollary: if the limit above is 0 then f(n) is O(g(n)), and if the limit is infinity then f(n) is
๎‚ถ๎‚žg๎‚žn๎‚Ÿ๎‚Ÿ
.
9.) if f(n) is
๎‚ฎ๎‚ž g๎‚žn๎‚Ÿ๎‚Ÿ
then
lim
n๎‚Œโˆž
f๎‚žn๎‚Ÿ
g๎‚žn๎‚Ÿ=c , where 0๎‚„c๎‚„โˆž
provided that the limit exists
10.) If K > 0 is a constant, then K is
๎‚ฎ๎‚ž1๎‚Ÿ
.
11.) A polynomial is
๎‚ฎ๎‚ž the highest power of n๎‚Ÿ
12.) K * f(n) is
๎‚ฎ๎‚ž f๎‚žn๎‚Ÿ๎‚Ÿ
[i.e. constants coefficients can be dropped]
13.) In general, f(n) is
๎‚ฎ
of the dominant term of f(n), where โ€œdominantโ€ may usually be determined from theorem 5
14.) for any base b, logb(n) is
)
15.) If f(n) is
๎‚ฎ๎‚ž g๎‚žn๎‚Ÿ๎‚Ÿ
and g(n) is
๎‚ฎ๎‚ž h๎‚žn๎‚Ÿ๎‚Ÿ
then f(n) is
๎‚ฎ๎‚ž h๎‚žn๎‚Ÿ๎‚Ÿ
16.) If f(n) is
๎‚ฎ๎‚ž g๎‚žn๎‚Ÿ๎‚Ÿ
then g(n) is
๎‚ฎ๎‚ž f๎‚žn๎‚Ÿ๎‚Ÿ
17.) If f(n) is
๎‚ฎ๎‚ž f๎‚žn๎‚Ÿ๎‚Ÿ
-by theorems 15-17,
๎‚ฎ
is an equivalence relation on the set of positive-valued functions
AVL Tree: a binary search tree in which the heights of the left and right subtrees of the root differ by at most 1, and in which the left
and right subtrees are themselves AVL trees.
Each node has a balance factor indicating the relative heights of left/right subtrees

Partial preview of the text

Download Finiteness - Data Structures and OO Development - Handout | CS 2606 and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Finiteness: Algorithm must complete after a finite number of instructions have been executed absence of Ambiguity: Each step must be clearly defines, having only one interpretation definition of Sequence: Each step must have a unique defined preceding and succeeding step. The first step (start step) and last step (halt step) must be clearly noted. input/Output: Number and types of required inputs and results must be specified. Feasibility: It must be possible to perform each instruction logn, n, nlogn, n^2, n^3, 2^n BigO: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is O(g(n)) provided that there are constants C

0 and N > 0 such that for all n > N, f(n) <= Cg(n). expresses and upper bound Theorems: 1.) K is O(1) 2.) A polynomial is O(the term containing the highest power of n) 3.) K*f(n) is O(f(n)) (i.e. you can drop constants) 4.) If f(n) is O(g(n)) and g(n) is O(h(n)) then f(n) is O(h(n)) [transitivity] 5.) K, logb(n), n, nlogb(n), n^2, n^higher power, 2^n, 3^n, larger constants^n, n!, n^n 6.) f(n) is O(the dominant term of f(n)) 7.) for any base b, logb(n) is O(log(n)) BigOmega: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is (^) ๎‚ถ๎‚žg ๎‚žn๎‚Ÿ๎‚Ÿ provided that there are constants C > 0 and N > 0 such that for all n > N, f(n) >= Cg(n). expresses a lower bound BigTheta: Suppose that f(n) and g(n) are nonnegative functions of n. Then we say that f(n) is ๎‚ฎ๎‚ž g๎‚ž n๎‚Ÿ๎‚Ÿ provided that f(n) is O(g(n)) and also that f(n) is (^) ๎‚ถ๎‚žg๎‚ž n๎‚Ÿ๎‚Ÿ. Theroems: 8.) f(n) is ๎‚ฎ๎‚ž g๎‚ž n๎‚Ÿ๎‚Ÿ if lim n ๎‚Œโˆž f ๎‚žn ๎‚Ÿ g ๎‚ž n๎‚Ÿ =c , where 0 ๎‚„c๎‚„โˆž

  1. corollary: if the limit above is 0 then f(n) is O(g(n)), and if the limit is infinity then f(n) is ๎‚ถ๎‚žg๎‚ž n๎‚Ÿ๎‚Ÿ. 9.) if f(n) is (^) ๎‚ฎ๎‚ž g๎‚ž n๎‚Ÿ๎‚Ÿ then (^) lim n ๎‚Œโˆž f ๎‚žn๎‚Ÿ g๎‚ž n๎‚Ÿ =c , where 0 ๎‚„c๎‚„โˆž provided that the limit exists 10.) If K > 0 is a constant, then K is ๎‚ฎ ๎‚ž 1 ๎‚Ÿ. 11.) A polynomial is (^) ๎‚ฎ๎‚ž the highest power of n๎‚Ÿ 12.) K * f(n) is ๎‚ฎ๎‚ž f ๎‚ž n๎‚Ÿ๎‚Ÿ [i.e. constants coefficients can be dropped] 13.) In general, f(n) is ๎‚ฎ of the dominant term of f(n), where โ€œdominantโ€ may usually be determined from theorem 5 14.) for any base b, logb(n) is (^) ๎‚ฎ๎‚ž log ๎‚ž n๎‚Ÿ๎‚Ÿ ) 15.) If f(n) is ๎‚ฎ๎‚ž g๎‚ž n๎‚Ÿ๎‚Ÿ and g(n) is ๎‚ฎ๎‚ž h๎‚ž n๎‚Ÿ๎‚Ÿ then f(n) is ๎‚ฎ๎‚ž h๎‚ž n๎‚Ÿ๎‚Ÿ 16.) If f(n) is ๎‚ฎ๎‚ž g๎‚ž n๎‚Ÿ๎‚Ÿ then g(n) is ๎‚ฎ๎‚ž f ๎‚ž n๎‚Ÿ๎‚Ÿ 17.) If f(n) is (^) ๎‚ฎ๎‚ž f ๎‚ž n๎‚Ÿ๎‚Ÿ by theorems 1517, ๎‚ฎ is an equivalence relation on the set of positivevalued functions AVL Tree: a binary search tree in which the heights of the left and right subtrees of the root differ by at most 1, and in which the left and right subtrees are themselves AVL trees. Each node has a balance factor indicating the relative heights of left/right subtrees