This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Supplementary: Order notation 1 Purpose and background This document covers some aspects of order notation for CS 136 students interested in going beyond what is covered in lecture. It can be read after the introduction of order notation in lecture module 01. While nothing in this document is required reading for CS 136, understanding what is covered here will help indirectly for required components of the course (assignments and exams). 2 The basic definition We saw this definition in lecture. Definition 1 : f ( n ) is O ( g ( n )) if there exist constants c and n such that for all n ≥ n , f ( n ) ≤ c · g ( n ) . Definition 1 expresses a relationship between two functions f ( n ) and g ( n ) . We sometimes use the equal sign to express this relationship, as in “ 3 n 2 + 6 n = O ( n 2 ) ”. But O ( n 2 ) is not a function, or an algebraic object, and so our mathematical intuition about what the equal sign means does not apply. We can’t say “ O ( n 2 ) = 3 n 2 + 6 n ”, for example. If we had to define O ( g ( n )) as a mathematical object, the next definition is probably the best choice. Definition 2 : O ( g ( n )) is the set of functions f ( n ) such that there exist constants c and n such that for all n ≥ n , f ( n ) ≤ c · g ( n ) . Some textbooks and papers use Definition 2, but most do not. It will help to keep Definition 2 in mind as we work through the implications of using Definition 1. What is so hard about these definitions? The difficulty arises in working with the underlined logical quantifiers they contain. Since we will be seeing them a lot, it is worth learning and using the symbolic short forms for them. “There exists” is written ∃ , and “for all” is written ∀ . Mathematical proofs make regular use of these quantifiers, but often they are not made explicit. 1 Here is another layout of Definition 1 that makes the structure clear. f ( n ) is O ( g ( n )) if: ∃ c ∃ n ∀ n ≥ n f ( n ) ≤ c · g ( n ) In lecture, we used Definition 1 to prove that 3 n 2 + 6 n is O ( n 2 ) , by choosing (say) c = 9 , n = 1 , and then arguing that for n ≥ 1 , 3 n 2 + 6 n ≤ 9 n 2 . This is unsatisfying in two respects. First, the numbers 9 and 1 were produced “magically”. Sure, they work, but how does one find them in general? Second, in practice we don’t really have to prove statements like “ 3 n 2 + 6 n is O ( n 2 ) ”. We have to prove, or at least justify, statements like “this algorithm has a worst-case running time of O ( n 2 ) ”. Statements of the first kind provide practice in the reasoning necessary to justify the steps we take to prove statements of the second kind. 3 Working with the basic definition Here is how a working mathematician might try to prove “ 3 n 2 + 6 n is O ( n 2 ) ” using Definition 1....
View Full Document
This note was uploaded on 10/21/2010 for the course CS 136 taught by Professor Becker during the Winter '08 term at Waterloo.
- Winter '08