Discrete Mathematics CS October 17, 2006
|
|
- Milton Patrick
- 5 years ago
- Views:
Transcription
1 Discrete Mathematics CS 2610 October 17, 2006
2 Uncountable sets Theorem: The set of real numbers is uncountable. If a subset of a set is uncountable, then the set is uncountable. The cardinality of a subset is at least as large as the cardinality of the entire set. It is enough to prove that there is a subset of R that is uncountable Theorem: The open interval of real numbers [0,1) = {r R 0 r < 1} is uncountable. Proof by contradiction using the Cantor diagonalization argument (Cantor, 1879) 2
3 Uncountable Sets: R Proof (BWOC) using diagonalization: Suppose R is countable (then any subset say [0,1) is also countable). So, we can list them: r 1, r 2, r 3, where r 1 = 0.d 11 d 12 d 13 d 14 the d ij are digits 0-9 r 2 = 0.d 21 d 22 d 23 d 24 r 3 = 0.d 31 d 32 d 33 d 34 r 4 = 0.d 41 d 42 d 43 d 44 etc. Now let r = 0.d 1 d 2 d 3 d 4 where d i = 4 if d ii 4 d i = 5 if d ii = 4 But r is not equal to any of the items in the list it s missing from the list so we can t list them after all. r differs from r i in the i th position, for all i. So, our assumption that we could list them all is incorrect. 3
4 Algorithms An Algorithm is a finite set of precise instructions for performing a computation or for solving a problem. Properties of an algorithm: - input: input values are from a specified set - output: output values are from a specified set - definiteness: each step is precisely defined - correctness: correct output produced - finiteness: takes a finite number of steps - effectiveness: each step is finite & exact - generality: applicable to various input sizes 4
5 Analysis of Algorithms Analyzing an algorithm Time complexity Space complexity Time complexity Running time needed by an algorithm as a function of the size of the input Denoted as T(N) We are interested in measuring how fast the time complexity increases as the input size grows Asymptotic Time Complexity of an Algorithm 5
6 Pseudocode procedure procname(argument: type) variable := expression informal statement begin statements end {comment} if condition then statement1 [else statement2] for variable := initial value to final value statement while condition statement return expression procname(arg1,..,argn) 6
7 Algorithm Complexity Worst Case Analysis Largest number of operations to solve a problem of a specified size. Analyze the worst input case for each input size. Upper bound of the running time for any input. Most widely used. Average Case Analysis Average number of operations over all inputs of a given size Sometimes it s too complicated 7
8 Example: Max Algorithm procedure max(a 1, a 2,, a n : integers) v := a 1 for i := 2 to n if a i > v then v := a i return v 1 n n - 1? 0, 1,.., n -1 1 How many times is each step executed? Worst-Case: the input sequence is a strictly increasing sequence 8
9 Searching Algorithms Searching Algorithms Problem: Find an element x in a list a 1, a n (not necessarily ordered) Linear Search Strategy: Examine the sequence one element after another until all the elements have been examined or the current element being examined is the element x. 9
10 Example: Linear Search procedure linear search (x: integer, a 1, a 2,, a n : distinct integers) i := 1 while (i n x a ) i i := i + 1 if i n then location := i else location := 0 return location Worst-Case occurs when x is the last element in the sequence Best Case occurs when x is the first element in the sequence 10
11 Example: Linear Search Average Case: x is the first element: 1 loop comparison x is the second element 2 loop comparisons, 1 iteration of the loop x is the third element 3 loop comparisons, 2 iterations of the loop x is n-th element n loop comparisons, n-1 iterations of the loop 11
12 Binary Search Problem: Locate an element x in a sequence of sorted elements in non-decreasing order. Strategy: On each step, look at the middle element of the remaining list to eliminate half of it, and quickly zero in on the desired element. 12
13 Binary Search procedure binary search (x:integer, a 1, a 2,, a n : integer) {a 1, a 2,, a n are distinct integers sorted smallest to largest} i := 1 {start of search range} j := n {end of search range} while i < j begin m := (i +j)/2 if x > a m then i := m + 1 else j := m end if x = a i then location := i else location := 0 return location Suppose n=2 k 13
14 Binary Search Binary Search The loop is executed k times k=log 2 (n) 14
15 Linear Search vs. Binary Search Linear Search Time Complexity: T(n) is O(n) Binary Search Time Complexity: T(n) is O(log 2 n) 15
16 Sorting Algorithms Problem: Given a sequence of numbers, sort the sequence in weakly increasing order. Sorting Algorithms: Input: A sequence of n numbers a 1, a 2,, a n Output: A reordering of the input sequence (a 1, a 2,, a n ) such that a 1 a 2 a n 16
17 Bubble Sort Smallest elements float up to the top (front) of the list, like bubbles in a container of liquid Largest elements sink to the bottom (end). See the animation at: 17
18 Example: Bubble Sort procedure bubblesort (a 1, a 2,, a n : distinct integers) for i = 1 to n-1 for j = 1 to n-i if (a j > a j+1 ) then swap a j and a j+1 Worst-Case: The sequence is sorted in decreasing order At step i The loop condition of the inner loop is executed n i + 1 times. The body of the loop is executed n i times 18
19 Algorithm- Insertion Sort For each element: The elements on its left are already sorted Shift the element with the element on the left until it is in the correct place. See animation 19
20 Algorithm- Insertion Sort procedure insertsort (a 1, a 2,, a n : distinct integers) for j=2 to n begin i=j - 1 while i > 0 and a i > a i+1 swap a i and a i+1 i=i-1 end Worst-Case: The sequence is in decreasing order At step j, the while loop condition is executed j times the body of the loop is executed j-1 times 20
21 Discrete Mathematics CS 2610 October 19, 2006
22 Algorithm- Insertion Sort For each element: The elements on its left are already sorted Shift the element with the element on the left until it is in the correct place. See animation 22
23 Algorithm- Insertion Sort procedure insertsort (a 1, a 2,, a n : distinct integers) for j=2 to n begin i=j - 1 end while i > 0 and a i > a i+1 swap a i and a i+1 i=i-1 Worst-Case: The sequence is in decreasing order At step j, the while loop condition is executed j times the body of the loop is executed j-1 times 23
24 Greedy Algorithms Problem: Assign meeting to conference rooms Policy: In decreasing order of room capacity, assign a meeting to the next largest available room Meeting 1: 70 Room A 200 M 1 Meeting 2: 46 Meeting 3: 125 Room B 150 Room C 150 M 2 Can you think of a better solution? M3 Meeting 4: 110 X Room D 100 M5 Meeting 5: 30 Room E 75 Meeting 6: 87 X Room F 50 24
25 Greedy Algorithm Policy: : In ascending order of room capacity, assign a meeting to the smallest room that can hold the meeting. Meeting 1:70 Meeting 2:46 Meeting 3:125 Meeting 4:110 Meeting 5:30 Meeting 6:87 Room F 50 Room E 75 Room D 100 Room C 150 Room B 150 Room A 200 M 2 M 1 M5 M3 M4 M6 25
26 Order of Growth Terminology Best O(1) Constant O(log cn) Logarithmic (c Z + ) O(log c n) Polylogarithmic (c Z + ) O(n) Linear O(n c ) Polynomial (c Z + ) O(c n ) Exponential (c Z + ) O(n!) Factorial Worst 26
27 Complexity of Problems Tractable A problem that can be solved with a deterministic polynomial (or better) worst-case time complexity. Also denoted as P Example: Search Problem Sorting problem Find the maximum 27
28 Complexity of Problems Intractable Problems that are not tractable. Example: Traveling salesperson problem Wide use of greedy algorithms to get an approximate solution. For example under certain circumstances you can get an approximation that is at most double the optimal solution. 28
29 P vs. NP NP: Solvable problems whose solution can be checked in polynomial time. P NP The most famous unproven conjecture in computer science is that this inclusion is proper. P NP rather than P=NP 29
30 Complexity of Problems Not Solvable Proven to have no algorithm that computes it Example: Halting problem (Alan Turing) Determine whether an arbitrary given algorithm, will eventually halt for any given finite input. Corollary: The question of whether or not a program halts for a given input is unsolvable. 30
31 Discrete Mathematics CS 2610 October 19, 2006
32 Big-O Notation Big-O notation is used to express the time complexity of an algorithm We can assume that any operation requires the same amount of time. The time complexity of an algorithm can be described independently of the software and hardware used to implement the algorithm. 32
33 Big-O Notation Def.: Let f, g be functions with domain R 0 or N and codomain R. f(x) is O(g(x)) if there are constants C and k st x > k, f (x ) C g (x ) f (x ) is asymptotically dominated by g (x ) C g(x) is an upper bound of f(x). C and k are called witnesses to the relationship between f & g. C g(x) f(x) k 33
34 Big-O Notation To prove that a function f(x) is O(g(x)) Find values for k and C, not necessarily the smallest one, larger values also work!! It is sufficient to find a certain k and C that works In many cases, for all x 0, if f(x) 0 then f(x) = f(x) Example: f(x) = x 2 + 2x + 1 is O(x 2 ) for C = 4 and k = 1 34
35 Big-O Notation Show that f(x) = x 2 + 2x + 1 is O(x 2 ). When x > 1 we know that x x 2 and 1 x 2 then 0 x 2 + 2x + 1 x 2 + 2x 2 + x 2 = 4x 2 so, let C = 4 and k = 1 as witnesses, i.e., f(x) = x 2 + 2x + 1 < 4x 2 when x > 1 Could try x > 2. Then we have 2x x 2 & 1 x 2 then 0 x 2 + 2x + 1 x 2 + x 2 + x 2 = 3x 2 so, C = 3 and k = 2 are also witnesses to f(x) being O(x 2 ). Note that f(x) is also O(x 3 ), etc. 35
36 Big-O Notation Show that f(x) = 7x 2 is O(x 3 ). When x > 7 we know that 7x 2 < x 3 (multiply x > 7 by x 2 ) so, let C = 1 and k = 7 as witnesses. Could try x > 1. Then we have 7x 2 < 7x 3 so, C = 7 and k = 1 are also witnesses to f(x) being O(x 3 ). Note that f(x) is also O(x 4 ), etc. 36
37 Big-O Notation Show that f(n) = n 2 is not O(n). Show that no pair of C and k exists such that n 2 Cn whenever n > k. When n > 0, divide both sides of n 2 Cn by n to get n C. No matter what C and k are, n C will not hold for all n with n > k. 37
38 Big-O Notation Observe that g(x) = x 2 is O(x 2 + 2x + 1) Def:Two functions f(x) and g(x) have the same order iff g(x) is O(f(x)) and f(x) is O(g(x)) 38
39 Big-O Notation Also, the function f(x) = 3x 2 + 2x + 3 is O(x 3 ) What about O(x 4 )? In fact, the function Cg(x) is an upper bound for f(x), but not necessarily the tightest bound. When Big-O notation is used, g(x) is chosen to be as small as possible. 39
40 Big-Oh - Theorem Theorem: If f(x) = a n x n + a n-1 x n a 1 x+ a 0 where a i R, i=0, n; then f(x) is O(x n ). Leading term dominates! Proof: if x > 1 we have f(x) = a n x n + a n-1 x n a 1 x+ a 0 a n x n + a n-1 x n a 1 x+ a 0 = x n ( a n + a n-1 /x + + a 1 /x n-1 + a 0 /x n ) x n ( a n + a n a 1 + a 0 ) So, f(x) Cx n where C = a n + a n a 1 + a 0 whenever x > 1 (what s k? k = 1, why?) What s this: a + b a + b 40
41 Big-O Example: Prove that f(n) = n! is O(n n ) Proof (easy): n! = n n n n n n n = n n where our witnesses are C = 1 and k = 1 Example: Prove that log(n!) is O(nlogn) Using the above, take the log of both sides: log(n!) log(n n ) which is equal to n log(n) 41
42 Big-O Lemma:A constant function is O(1). Proof: Left to the viewer The most common functions used to estimate the time complexity of an algorithm. (in increasing O() order): 1, (log n), n, (n log n), n 2, n 3, 2 n, n! 42
43 Big-O Properties Transitivity:if f is O(g) and g is O(h) then f is O(h) Sum Rule: If f 1 is O(g 1 ) and f 2 is O(g 2 ) then f 1 +f 2 is O(max( g 1, g 2 )) If f 1 is O(g) and f 2 is O(g) then f 1 +f 2 is O(g) Product Rule If f 1 is O(g 1 ) andf 2 is O(g 2 ) then f 1 f 2 is O(g 1 g 2 ) For all c > 0, O(cf), O(f + c),o(f c) are O(f) 43
44 Big-O Properties Example Example: Give a big-o estimate for 3n log (n!) + (n 2 +3)log n, n>0 1) For 3n log (n!) we know log(n!) is O(nlogn) and 3n is O(n) so we know 3n log(n!) is O(n 2 logn) 2) For (n 2 +3)log n we have (n 2 +3) < 2n 2 when n > 2 so it s O(n 2 ); and (n 2 +3)log n is O(n 2 log n) 3) Finally we have an estimate for 3n log (n!) + (n 2 +3)log n that is: O(n 2 log n) 44
45 Big-O Notation Def.:Functions f and g are incomparable, if f(x) is not O(g) and g is not O(f). f: R + R, f(x) = 5 x 1.5 g: R + R, g(x) = x 2 sin x x x 2 sin x x
46 Big-Omega Notation Def.: Let f, g be functions with domain R 0 or N and codomain R. f(x) is Ω(g(x)) if there are positive constants C and k such that x > k, C g (x ) f (x ) C g(x) is a lower bound for f(x) f(x) C g(x) k 46
47 Big-Omega Property Theorem: f(x) is Ω(g(x)) iff g(x) is O(f(x)). Is the trivial or what? 47
48 Big-Omega Property Example: prove that f(x) = 3x 2 + 2x + 3 is Ω(g(x)) where g(x) = x 2 Proof: first note that 3x 2 + 2x + 3 3x 2 for all x 0. That s the same as saying that g(x) = x 2 is O(3x 2 + 2x + 3) 48
49 Big-Theta Notation Def.:Let f, g be functions with domain R 0 or N and codomain R. f(x) is Θ(g(x)) if f(x) is O(g(x)) and f(x) is Ω(g(x)). C 2 g(x) f(x) C 1 g(x) 49
50 Big-Theta Notation When f(x) is Θ(g(x)), we know that g(x) is Θ(f(x)). Also, f(x) is Θ(g(x)) iff f(x) is O(g(x)) and g(x) is O(f(x)). Typical g functions: x n, c x, log x, etc. 50
51 Big-Theta Notation To prove that f(x) is order g(x) Method 1 Prove that f is O(g(x)) Prove that f is Ω(g(x)) Method 2 Prove that f is O(g(x)) Prove that g is O(f(x)) 51
52 Big-Theta Example show that 3x 2 + 8x log x is Θ(x 2 ) (or order x 2 ) 0 8x log x 8x 2 so 3x 2 + 8x log x 11x 2 for x > 1. So, 3x 2 + 8x log x is O(x 2 ) (can I get a witness?) Is x 2 O(3x 2 + 8x log x)? You betcha! Why? Therefore, 3x 2 + 8x log x is Θ(x 2 ) 52
53 Big Summary Upper Bound Use Big-Oh Lower Bound Use Big-Omega Upper and Lower (or Order of Growth) Use Big-Theta 53
54 Time to Shift Gears Again Number Theory Number Theory Livin Large 54
55 Discrete Mathematics CS 2610 October 19, 2006
56 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers Modular arithmetic Some Applications Cryptography E-commerce Payment systems Random number generation Coding theory Hash functions (as opposed to stew functions ) 56
57 Number Theory - Division Let a, b and c be integers, st a 0, we say that a divides b or a b if there is an integer c where b = a c. a and c are said to divide b (or are factors) a b c b b is a multiple of both a and c Example: 5 30 and 5 55 but
58 Number Theory - Division Theorem 3.4.1: for all a, b, c Z: 1. a 0 2. (a b a c) a (b + c) 3. a b a bc for all integers c 4. (a b b c) a c Proof: (2) a b means b = ap, and a c means c = aq b + c = ap + aq = a(p + q) therefore, a (b + c), or (b + c) = ar where r = p+q Proof: (4) a b means b = ap, and b c means c = bq c = bq = apq therefore, a c or c = ar where r = pq 58
59 Division Remember long division? = a = dq + r (dividend = divisor quotient + remainder) 59
60 The Division Algorithm Division Algorithm Theorem: Let a be an integer, and d be a positive integer. There are unique integers q, r with r {0,1,2,,d-1} (ie, 0 r < d) satisfying d is the divisor q is the quotient q = a div d a = dq + r r is the remainder r = a mod d 60
61 Mod Operation Let a, b Z with b > 1. a = q b + r, where 0 r < b Then a mod b denotes the remainder r from the division algorithm with dividend a and divisor b 109 mod 30 =? 0 a mod b b 1 61
62 Modular Arithmetic Let a, b Z, m Z + Then a is congruent to b modulo m iff m (a b). Notation: a b (mod m) reads a is congruent to b modulo m a b (mod m) reads a is not congruent to b modulo m. Examples: 5 25 (mod 10) 5 25 (mod 2) 62
63 Modular Arithmetic Theorem 3.4.3: Let a, b Z, m Z +. Then a b (mod m) iff a mod m = b mod m Proof: (1) given a mod m = b mod m we have a = ms + r or r = a ms, b = mp + r or r = b mp, a ms = b mp which means a b = ms mp = m(s p) so m (a b) which means a b (mod m) 63
64 Modular Arithmetic Theorem 3.4.3: Let a, b Z, m Z +. Then a b (mod m) iff a mod m = b mod m Proof: (2) given a b (mod m) we have m (a b) let a = mq a + r a and b = mq b + r b so, m ((mq a + r a ) (mq b + r b )) or m m(q a q b ) + (r a r b ) recall 0 r a < m and 0 r b < m therefore (r a r b ) must be 0 that is, the two remainders are the same which is the same as saying a mod m = b mod m 64
65 Modular Arithmetic Theorem 3.4.4: Let a, b Z, m Z +. Then: a b (mod m) iff there exists a k Z st a = b + km. Proof: a = b + km means a b = km which means m (a b) which is the same as saying a b (mod m) (to complete the proof, reverse the steps) Examples: (mod 5) 27 = k k = (mod 10) 105 = k k = 15 65
66 Modular Arithmetic Theorem 3.4.5: Let a, b, c, d Z, m Z +. Then if a b (mod m) and c d (mod m), then: 1. a + c b + d (mod m), 2. a - c b - d (mod m), 3. ac bd (mod m) Proof: a = b + k 1 m and c = d + k 2 m a + c = b + d + k 1 m + k 2 m or a + c = b + d + m(k 1 + k 2 ) which is a + c b + d (mod m) others are similar 66
3 The Fundamentals:Algorithms, the Integers, and Matrices
3 The Fundamentals:Algorithms, the Integers, and Matrices 3.1 Algrithms Definition 1 An algorithm is a finite set of instructions for performing a computation or solving a problem. Dijkstra s mini language
More informationAlgorithms and Their Complexity
CSCE 222 Discrete Structures for Computing David Kebo Houngninou Algorithms and Their Complexity Chapter 3 Algorithm An algorithm is a finite sequence of steps that solves a problem. Computational complexity
More information3. Algorithms. What matters? How fast do we solve the problem? How much computer resource do we need?
3. Algorithms We will study algorithms to solve many different types of problems such as finding the largest of a sequence of numbers sorting a sequence of numbers finding the shortest path between two
More informationCOMP 182 Algorithmic Thinking. Algorithm Efficiency. Luay Nakhleh Computer Science Rice University
COMP 182 Algorithmic Thinking Algorithm Efficiency Luay Nakhleh Computer Science Rice University Chapter 3, Sections 2-3 Reading Material Not All Correct Algorithms Are Created Equal We often choose the
More informationCSCE 222 Discrete Structures for Computing
CSCE 222 Discrete Structures for Computing Algorithms Dr. Philip C. Ritchey Introduction An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem.
More informationCS March 17, 2009
Discrete Mathematics CS 2610 March 17, 2009 Number Theory Elementary number theory, concerned with numbers, usually integers and their properties or rational numbers mainly divisibility among integers
More informationAnnouncements. CompSci 102 Discrete Math for Computer Science. Chap. 3.1 Algorithms. Specifying Algorithms
CompSci 102 Discrete Math for Computer Science Announcements Read for next time Chap. 3.1-3.3 Homework 3 due Tuesday We ll finish Chapter 2 first today February 7, 2012 Prof. Rodger Chap. 3.1 Algorithms
More informationAnnouncements. CompSci 230 Discrete Math for Computer Science. The Growth of Functions. Section 3.2
CompSci 230 Discrete Math for Computer Science Announcements Read Chap. 3.1-3.3 No recitation Friday, Oct 11 or Mon Oct 14 October 8, 2013 Prof. Rodger Section 3.2 Big-O Notation Big-O Estimates for Important
More informationAlgorithms 2/6/2018. Algorithms. Enough Mathematical Appetizers! Algorithm Examples. Algorithms. Algorithm Examples. Algorithm Examples
Enough Mathematical Appetizers! Algorithms What is an algorithm? Let us look at something more interesting: Algorithms An algorithm is a finite set of precise instructions for performing a computation
More informationTheory of Computation
Theory of Computation Unit 4-6: Turing Machines and Computability Decidability and Encoding Turing Machines Complexity and NP Completeness Syedur Rahman syedurrahman@gmail.com Turing Machines Q The set
More informationECOM Discrete Mathematics
ECOM 2311- Discrete Mathematics Chapter # 3 : Algorithms Fall, 2013/2014 ECOM 2311- Discrete Mathematics - Ch.3 Dr. Musbah Shaat 1 / 41 Outline 1 Algorithms 2 The Growth of Functions 3 Complexity of Algorithms
More informationWith Question/Answer Animations
Chapter 3 With Question/Answer Animations Copyright McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education. Chapter Summary
More informationCS481: Bioinformatics Algorithms
CS481: Bioinformatics Algorithms Can Alkan EA224 calkan@cs.bilkent.edu.tr http://www.cs.bilkent.edu.tr/~calkan/teaching/cs481/ Reminder The TA will hold a few recitation sessions for the students from
More informationAlgorithms: Review from last time
EECS 203 Spring 2016 Lecture 9 Page 1 of 9 Algorithms: Review from last time 1. For what values of C and k (if any) is it the case that x 2 =O(100x 2 +4)? 2. For what values of C and k (if any) is it the
More informationDiscrete Math Notes. Contents. William Farmer. April 8, Overview 3
April 8, 2014 Contents 1 Overview 3 2 Principles of Counting 3 2.1 Pigeon-Hole Principle........................ 3 2.2 Permutations and Combinations.................. 3 2.3 Binomial Coefficients.........................
More informationAnalysis of Algorithms
Analysis of Algorithms Section 4.3 Prof. Nathan Wodarz Math 209 - Fall 2008 Contents 1 Analysis of Algorithms 2 1.1 Analysis of Algorithms....................... 2 2 Complexity Analysis 4 2.1 Notation
More informationRemainders. We learned how to multiply and divide in elementary
Remainders We learned how to multiply and divide in elementary school. As adults we perform division mostly by pressing the key on a calculator. This key supplies the quotient. In numerical analysis and
More informationAlgorithm. Executing the Max algorithm. Algorithm and Growth of Functions Benchaporn Jantarakongkul. (algorithm) ก ก. : ก {a i }=a 1,,a n a i N,
Algorithm and Growth of Functions Benchaporn Jantarakongkul 1 Algorithm (algorithm) ก ก ก ก ก : ก {a i }=a 1,,a n a i N, ก ก : 1. ก v ( v ก ก ก ก ) ก ก a 1 2. ก a i 3. a i >v, ก v ก a i 4. 2. 3. ก ก ก
More informationMATH 363: Discrete Mathematics
MATH 363: Discrete Mathematics Learning Objectives by topic The levels of learning for this class are classified as follows. 1. Basic Knowledge: To recall and memorize - Assess by direct questions. The
More informationSlides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Spring 2006
Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Spring 2006 1 / 1 Computer Science & Engineering 235 Introduction to Discrete Mathematics Sections 2.4 2.6 of Rosen Introduction I When talking
More informationNOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty.
EXAM 2 solutions (COT3100, Sitharam, Spring 2017) NAME:last first: UF-ID Section NOTE: You have 2 hours, please plan your time. Problems are not ordered by difficulty. (1) Are the following functions one-to-one
More informationWith Question/Answer Animations. Chapter 4
With Question/Answer Animations Chapter 4 Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their properties. Key ideas in number theory include divisibility
More informationTime Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)
Time Complexity (1) CSCI 2670 Original Slides were written by Dr. Frederick W Maier Spring 2014 Time Complexity So far we ve dealt with determining whether or not a problem is decidable. But even if it
More informationLimitations of Algorithm Power
Limitations of Algorithm Power Objectives We now move into the third and final major theme for this course. 1. Tools for analyzing algorithms. 2. Design strategies for designing algorithms. 3. Identifying
More informationGrowth of Functions. As an example for an estimate of computation time, let us consider the sequential search algorithm.
Function Growth of Functions Subjects to be Learned Contents big oh max function big omega big theta little oh little omega Introduction One of the important criteria in evaluating algorithms is the time
More informationMat Week 6. Fall Mat Week 6. Algorithms. Properties. Examples. Searching. Sorting. Time Complexity. Example. Properties.
Fall 2013 Student Responsibilities Reading: Textbook, Section 3.1 3.2 Assignments: 1. for sections 3.1 and 3.2 2. Worksheet #4 on Execution s 3. Worksheet #5 on Growth Rates Attendance: Strongly Encouraged
More informationStudent Responsibilities Week 6. Mat Properties of Algorithms. 3.1 Algorithms. Finding the Maximum Value in a Finite Sequence Pseudocode
Student Responsibilities Week 6 Mat 345 Week 6 Reading: Textbook, Section 3.1 3. Assignments: 1. for sections 3.1 and 3.. Worksheet #4 on Execution Times 3. Worksheet #5 on Growth Rates Attendance: Strongly
More informationAnalysis of Algorithm Efficiency. Dr. Yingwu Zhu
Analysis of Algorithm Efficiency Dr. Yingwu Zhu Measure Algorithm Efficiency Time efficiency How fast the algorithm runs; amount of time required to accomplish the task Our focus! Space efficiency Amount
More informationLecture 6: Introducing Complexity
COMP26120: Algorithms and Imperative Programming Lecture 6: Introducing Complexity Ian Pratt-Hartmann Room KB2.38: email: ipratt@cs.man.ac.uk 2015 16 You need this book: Make sure you use the up-to-date
More informationDiscrete Mathematics CS
Discrete Mathematics CS 2610 1 Propositional Logic: Precedence By convention Examples: Logical Operator Precedence 1 2 3 4 5 p q r is equivalent to (( p) q) r p q r s is equivalent to p (q (r s)) 2 Logic
More informationName (please print) Mathematics Final Examination December 14, 2005 I. (4)
Mathematics 513-00 Final Examination December 14, 005 I Use a direct argument to prove the following implication: The product of two odd integers is odd Let m and n be two odd integers Since they are odd,
More informationThe Growth of Functions (2A) Young Won Lim 4/6/18
Copyright (c) 2015-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published
More informationSets. We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth
Sets We discuss an informal (naive) set theory as needed in Computer Science. It was introduced by G. Cantor in the second half of the nineteenth century. Most students have seen sets before. This is intended
More information5 + 9(10) + 3(100) + 0(1000) + 2(10000) =
Chapter 5 Analyzing Algorithms So far we have been proving statements about databases, mathematics and arithmetic, or sequences of numbers. Though these types of statements are common in computer science,
More informationIntegers and Division
Integers and Division Notations Z: set of integers N : set of natural numbers R: set of real numbers Z + : set of positive integers Some elements of number theory are needed in: Data structures, Random
More informationComputer Algorithms CISC4080 CIS, Fordham Univ. Outline. Last class. Instructor: X. Zhang Lecture 2
Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula
More informationComputer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2
Computer Algorithms CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Lecture 2 Outline Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive formula
More informationMATH 3300 Test 1. Name: Student Id:
Name: Student Id: There are nine problems (check that you have 9 pages). Solutions are expected to be short. In the case of proofs, one or two short paragraphs should be the average length. Write your
More informationCPSC 467: Cryptography and Computer Security
CPSC 467: Cryptography and Computer Security Michael J. Fischer Lecture 9 September 30, 2015 CPSC 467, Lecture 9 1/47 Fast Exponentiation Algorithms Number Theory Needed for RSA Elementary Number Theory
More informationCISC 235: Topic 1. Complexity of Iterative Algorithms
CISC 235: Topic 1 Complexity of Iterative Algorithms Outline Complexity Basics Big-Oh Notation Big-Ω and Big-θ Notation Summations Limitations of Big-Oh Analysis 2 Complexity Complexity is the study of
More informationPart IA Numbers and Sets
Part IA Numbers and Sets Definitions Based on lectures by A. G. Thomason Notes taken by Dexter Chua Michaelmas 2014 These notes are not endorsed by the lecturers, and I have modified them (often significantly)
More informationCopyright 2000, Kevin Wayne 1
Algorithm runtime analysis and computational tractability Time Complexity of an Algorithm How do we measure the complexity (time, space requirements) of an algorithm. 1 microsecond? Units of time As soon
More informationMATH FINAL EXAM REVIEW HINTS
MATH 109 - FINAL EXAM REVIEW HINTS Answer: Answer: 1. Cardinality (1) Let a < b be two real numbers and define f : (0, 1) (a, b) by f(t) = (1 t)a + tb. (a) Prove that f is a bijection. (b) Prove that any
More informationChapter 1 : The language of mathematics.
MAT 200, Logic, Language and Proof, Fall 2015 Summary Chapter 1 : The language of mathematics. Definition. A proposition is a sentence which is either true or false. Truth table for the connective or :
More informationRegister machines L2 18
Register machines L2 18 Algorithms, informally L2 19 No precise definition of algorithm at the time Hilbert posed the Entscheidungsproblem, just examples. Common features of the examples: finite description
More informationAnalysis of Algorithms
October 1, 2015 Analysis of Algorithms CS 141, Fall 2015 1 Analysis of Algorithms: Issues Correctness/Optimality Running time ( time complexity ) Memory requirements ( space complexity ) Power I/O utilization
More informationAsymptotic Analysis. Thomas A. Anastasio. January 7, 2004
Asymptotic Analysis Thomas A. Anastasio January 7, 004 1 Introduction As a programmer, you often have a choice of data structures and algorithms. Choosing the best one for a particular job involves, among
More informationTopic 17. Analysis of Algorithms
Topic 17 Analysis of Algorithms Analysis of Algorithms- Review Efficiency of an algorithm can be measured in terms of : Time complexity: a measure of the amount of time required to execute an algorithm
More informationNotes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.
Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr. Chapter : Logic Topics:. Statements, Negation, and Compound Statements.2 Truth Tables and Logical Equivalences.3
More informationRunning Time Evaluation
Running Time Evaluation Quadratic Vs. Linear Time Lecturer: Georgy Gimel farb COMPSCI 220 Algorithms and Data Structures 1 / 19 1 Running time 2 Examples 3 Big-Oh, Big-Omega, and Big-Theta Tools 4 Time
More information3 The fundamentals: Algorithms, the integers, and matrices
3 The fundamentals: Algorithms, the integers, and matrices 3.4 The integers and division This section introduces the basics of number theory number theory is the part of mathematics involving integers
More information4 Number Theory and Cryptography
4 Number Theory and Cryptography 4.1 Divisibility and Modular Arithmetic This section introduces the basics of number theory number theory is the part of mathematics involving integers and their properties.
More informationCOT 3100 Applications of Discrete Structures Dr. Michael P. Frank
University of Florida Dept. of Computer & Information Science & Engineering COT 3100 Applications of Discrete Structures Dr. Michael P. Frank Slides for a Course Based on the Text Discrete Mathematics
More informationCSCE 750, Spring 2001 Notes 1 Page 1 An outline of the book 1. Analyzing algorithms 2. Data abstraction 3. Recursion and induction 4. Sorting 5. Selec
CSCE 750, Spring 2001 Notes 1 Page 1 An outline of the book 1. Analyzing algorithms 2. Data abstraction 3. Recursion and induction 4. Sorting 5. Selection and adversary arguments 6. Dynamic sets and searching
More informationDescribe an algorithm for finding the smallest integer in a finite sequence of natural numbers.
Homework #4 Problem One (2.1.2) Determine which characteristics o f an algorithm the following procedures have and which they lack. a) procedure double(n: positive integer) while n > 0 n := 2n Since n
More informationNotes on Systems of Linear Congruences
MATH 324 Summer 2012 Elementary Number Theory Notes on Systems of Linear Congruences In this note we will discuss systems of linear congruences where the moduli are all different. Definition. Given the
More informationMathematics Course 111: Algebra I Part I: Algebraic Structures, Sets and Permutations
Mathematics Course 111: Algebra I Part I: Algebraic Structures, Sets and Permutations D. R. Wilkins Academic Year 1996-7 1 Number Systems and Matrix Algebra Integers The whole numbers 0, ±1, ±2, ±3, ±4,...
More informationAlgorithmic number theory. Questions/Complaints About Homework? The division algorithm. Division
Questions/Complaints About Homework? Here s the procedure for homework questions/complaints: 1. Read the solutions first. 2. Talk to the person who graded it (check initials) 3. If (1) and (2) don t work,
More informationInput Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary
Complexity Analysis Complexity Theory Input Decidable Language -- Program Halts on all Input Encoding of Input -- Natural Numbers Encoded in Binary or Decimal, Not Unary Output TRUE or FALSE Time and Space
More information1 Partitions and Equivalence Relations
Today we re going to talk about partitions of sets, equivalence relations and how they are equivalent. Then we are going to talk about the size of a set and will see our first example of a diagonalisation
More informationCSED233: Data Structures (2017F) Lecture4: Analysis of Algorithms
(2017F) Lecture4: Analysis of Algorithms Daijin Kim CSE, POSTECH dkim@postech.ac.kr Running Time Most algorithms transform input objects into output objects. The running time of an algorithm typically
More informationCSC 8301 Design & Analysis of Algorithms: Lower Bounds
CSC 8301 Design & Analysis of Algorithms: Lower Bounds Professor Henry Carter Fall 2016 Recap Iterative improvement algorithms take a feasible solution and iteratively improve it until optimized Simplex
More informationComputational Complexity - Pseudocode and Recursions
Computational Complexity - Pseudocode and Recursions Nicholas Mainardi 1 Dipartimento di Elettronica e Informazione Politecnico di Milano nicholas.mainardi@polimi.it June 6, 2018 1 Partly Based on Alessandro
More informationAnalysis of Algorithms. Unit 5 - Intractable Problems
Analysis of Algorithms Unit 5 - Intractable Problems 1 Intractable Problems Tractable Problems vs. Intractable Problems Polynomial Problems NP Problems NP Complete and NP Hard Problems 2 In this unit we
More informationBig O Notation. P. Danziger
1 Comparing Algorithms We have seen that in many cases we would like to compare two algorithms. Generally, the efficiency of an algorithm can be guaged by how long it takes to run as a function of the
More informationLecture 2. Fundamentals of the Analysis of Algorithm Efficiency
Lecture 2 Fundamentals of the Analysis of Algorithm Efficiency 1 Lecture Contents 1. Analysis Framework 2. Asymptotic Notations and Basic Efficiency Classes 3. Mathematical Analysis of Nonrecursive Algorithms
More informationDiscrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 27
CS 70 Discrete Mathematics for CS Spring 007 Luca Trevisan Lecture 7 Infinity and Countability Consider a function f that maps elements of a set A (called the domain of f ) to elements of set B (called
More informationSequences are ordered lists of elements
Sequences are ordered lists of elements Definition: A sequence is a function from the set of integers, either set {0,1,2,3, } or set {1,2,3,4,..}, to a set S. We use the notation a n to denote the image
More informationThe P-vs-NP problem. Andrés E. Caicedo. September 10, 2011
The P-vs-NP problem Andrés E. Caicedo September 10, 2011 This note is based on lecture notes for the Caltech course Math 6c, prepared with A. Kechris and M. Shulman. 1 Decision problems Consider a finite
More informationBig O 2/14/13. Administrative. Does it terminate? David Kauchak cs302 Spring 2013
/4/3 Administrative Big O David Kauchak cs3 Spring 3 l Assignment : how d it go? l Assignment : out soon l CLRS code? l Videos Insertion-sort Insertion-sort Does it terminate? /4/3 Insertion-sort Loop
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand 1 Divisibility, prime numbers By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a
More informationBasic elements of number theory
Cryptography Basic elements of number theory Marius Zimand By default all the variables, such as a, b, k, etc., denote integer numbers. Divisibility a 0 divides b if b = a k for some integer k. Notation
More informationWORKSHEET MATH 215, FALL 15, WHYTE. We begin our course with the natural numbers:
WORKSHEET MATH 215, FALL 15, WHYTE We begin our course with the natural numbers: N = {1, 2, 3,...} which are a subset of the integers: Z = {..., 2, 1, 0, 1, 2, 3,... } We will assume familiarity with their
More informationNOTES ON SIMPLE NUMBER THEORY
NOTES ON SIMPLE NUMBER THEORY DAMIEN PITMAN 1. Definitions & Theorems Definition: We say d divides m iff d is positive integer and m is an integer and there is an integer q such that m = dq. In this case,
More informationCSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis. Ruth Anderson Winter 2019
CSE332: Data Structures & Parallelism Lecture 2: Algorithm Analysis Ruth Anderson Winter 2019 Today Algorithm Analysis What do we care about? How to compare two algorithms Analyzing Code Asymptotic Analysis
More informationCOMPUTER ARITHMETIC. 13/05/2010 cryptography - math background pp. 1 / 162
COMPUTER ARITHMETIC 13/05/2010 cryptography - math background pp. 1 / 162 RECALL OF COMPUTER ARITHMETIC computers implement some types of arithmetic for instance, addition, subtratction, multiplication
More informationProblem-Solving via Search Lecture 3
Lecture 3 What is a search problem? How do search algorithms work and how do we evaluate their performance? 1 Agenda An example task Problem formulation Infrastructure for search algorithms Complexity
More informationComputer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms
Computer Science 385 Analysis of Algorithms Siena College Spring 2011 Topic Notes: Limitations of Algorithms We conclude with a discussion of the limitations of the power of algorithms. That is, what kinds
More informationAsymptotic Notation. such that t(n) cf(n) for all n n 0. for some positive real constant c and integer threshold n 0
Asymptotic Notation Asymptotic notation deals with the behaviour of a function in the limit, that is, for sufficiently large values of its parameter. Often, when analysing the run time of an algorithm,
More informationThe Complexity of Optimization Problems
The Complexity of Optimization Problems Summary Lecture 1 - Complexity of algorithms and problems - Complexity classes: P and NP - Reducibility - Karp reducibility - Turing reducibility Uniform and logarithmic
More informationAlgorithms (II) Yu Yu. Shanghai Jiaotong University
Algorithms (II) Yu Yu Shanghai Jiaotong University Chapter 1. Algorithms with Numbers Two seemingly similar problems Factoring: Given a number N, express it as a product of its prime factors. Primality:
More informationCSE 20: Discrete Mathematics
Spring 2018 Summary So far: Today: Logic and proofs Divisibility, modular arithmetics Number Systems More logic definitions and proofs Reading: All of Chap. 1 + Chap 4.1, 4.2. Divisibility P = 5 divides
More informationLogic. Introduction. Propositions and Propositional Calculus
www.csitportal.com Chapter - Introduction Discrete Structur Introduction Discrete Mathematics deals with discrete objects. Discrete objects are those objects that can be counted and are not connected for
More informationThe Beauty and Joy of Computing
The Beauty and Joy of Computing Lecture #23 Limits of Computing UC Berkeley EECS Sr Lecturer SOE Dan Researchers at CMU have built a system which searches the Web for images constantly and tries to decide
More information2WF15 - Discrete Mathematics 2 - Part 1. Algorithmic Number Theory
1 2WF15 - Discrete Mathematics 2 - Part 1 Algorithmic Number Theory Benne de Weger version 0.54, March 6, 2012 version 0.54, March 6, 2012 2WF15 - Discrete Mathematics 2 - Part 1 2 2WF15 - Discrete Mathematics
More informationMath 230 Final Exam, Spring 2008
c IIT Dept. Applied Mathematics, May 15, 2008 1 PRINT Last name: Signature: First name: Student ID: Math 230 Final Exam, Spring 2008 Conditions. 2 hours. No book, notes, calculator, cell phones, etc. Part
More informationMath.3336: Discrete Mathematics. Primes and Greatest Common Divisors
Math.3336: Discrete Mathematics Primes and Greatest Common Divisors Instructor: Dr. Blerina Xhabli Department of Mathematics, University of Houston https://www.math.uh.edu/ blerina Email: blerina@math.uh.edu
More informationFinite Fields. Mike Reiter
1 Finite Fields Mike Reiter reiter@cs.unc.edu Based on Chapter 4 of: W. Stallings. Cryptography and Network Security, Principles and Practices. 3 rd Edition, 2003. Groups 2 A group G, is a set G of elements
More informationAnalysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College
Analysis of Algorithms [Reading: CLRS 2.2, 3] Laura Toma, csci2200, Bowdoin College Why analysis? We want to predict how the algorithm will behave (e.g. running time) on arbitrary inputs, and how it will
More informationAnalysis of Algorithms
Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Analysis of Algorithms Input Algorithm Analysis
More informationCS1210 Lecture 23 March 8, 2019
CS1210 Lecture 23 March 8, 2019 HW5 due today In-discussion exams next week Optional homework assignment next week can be used to replace a score from among HW 1 3. Will be posted some time before Monday
More informationThe next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.
CS 70 Discrete Mathematics for CS Fall 2003 Wagner Lecture 10 The next sequence of lectures in on the topic of Arithmetic Algorithms. We shall build up to an understanding of the RSA public-key cryptosystem.
More informationAlgorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang
Algorithm Analysis, Asymptotic notations CISC4080 CIS, Fordham Univ. Instructor: X. Zhang Last class Introduction to algorithm analysis: fibonacci seq calculation counting number of computer steps recursive
More informationNumber Theory. Modular Arithmetic
Number Theory The branch of mathematics that is important in IT security especially in cryptography. Deals only in integer numbers and the process can be done in a very fast manner. Modular Arithmetic
More informationMore Polynomial Equations Section 6.4
MATH 11009: More Polynomial Equations Section 6.4 Dividend: The number or expression you are dividing into. Divisor: The number or expression you are dividing by. Synthetic division: Synthetic division
More informationComputational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9
1 Computational Complexity and Intractability: An Introduction to the Theory of NP Chapter 9 2 Objectives Classify problems as tractable or intractable Define decision problems Define the class P Define
More information(2) Generalize De Morgan s laws for n sets and prove the laws by induction. 1
ARS DIGITA UNIVERSITY MONTH 2: DISCRETE MATHEMATICS PROFESSOR SHAI SIMONSON PROBLEM SET 2 SOLUTIONS SET, FUNCTIONS, BIG-O, RATES OF GROWTH (1) Prove by formal logic: (a) The complement of the union of
More informationThe Beauty and Joy of Computing
The Beauty and Joy of Computing Lecture #23 Limits of Computing UC Berkeley EECS Sr Lecturer SOE Dan You ll have the opportunity for extra credit on your project! After you submit it, you can make a 5min
More informationCSE 417: Algorithms and Computational Complexity
CSE 417: Algorithms and Computational Complexity Lecture 2: Analysis Larry Ruzzo 1 Why big-o: measuring algorithm efficiency outline What s big-o: definition and related concepts Reasoning with big-o:
More informationGrowth of Functions (CLRS 2.3,3)
Growth of Functions (CLRS 2.3,3) 1 Review Last time we discussed running time of algorithms and introduced the RAM model of computation. Best-case running time: the shortest running time for any input
More information