CSCE 222 Discrete Structures for Computing. Review for Exam 2. Dr. Hyunyoung Lee !!!
|
|
- Roberta Gaines
- 5 years ago
- Views:
Transcription
1 CSCE 222 Discrete Structures for Computing Review for Exam 2 Dr. Hyunyoung Lee 1
2 Strategy for Exam Preparation - Start studying now (unless have already started) - Study class notes (lecture slides and lecture notes) and make sure you know your definitions - Review homework, quizzes, and in-class exercises - Study the examples in the textbook - Do odd numbered exercises - Bring a scantron: 8x11 gray 2
3 Exam Coverage The second exam will cover everything you have learned up to March 27, but the emphasis is on the material that we have covered after the first exam. Asymptotic Notations (Section 3.2) Time complexity of algorithms (Section 3.3) Sequences and sums (Section 2.4) Proof by induction and strong induction (Sections 5.1 and 5.2) Inductive sets, recursive functions, and structural induction (Section 5.3) Counting (Sections ) 3
4 Asymptotic Notations 4
5 Big Oh Notation Let f,g: N -> R be functions from the natural numbers to the set of real numbers. We write f O(g) if and only if there exists some real number n 0 and a positive real constant U such that f(n) <= U g(n) for all n satisfying n >= n 0 5
6 Set Interpretation We have interpreted f(n)=o(g(n)) as a relation between the two functions f(n) and g(n). We can give O(g(n)) a meaning by interpreting it as the set of all functions f(n) such that f(n)=o(g(n)), that is, O(g) = { f: N-> R there exists a constant U and a natural number n 0 such that f(n) <= U g(n) for all n >= n 0 } 6
7 Example O(n 2 ) 7
8 Big Ω We define f(n) Ω(g(n)) if and only if there exist a positive real constant L and a natural number n 0 such that L g(n) <= f(n) holds for all n >= n 0. In other words, f(n) = Ω(g(n)) if and only if g(n) = O(f(n)). 8
9 Big Θ We define f(n) Θ(g(n)) if and only if there exist positive real constants L and U and a natural number n 0 such that L g(n) <= f(n) <= U g(n) holds for all n >= n 0. In other words, f(n) = Θ(g(n)) if and only if f(n) = Ω(g(n)) and f(n) = O(g(n)). 9
10 Informal Summary f(n) = O(g(n)) means that f(n) is upper bounded by a constant multiple of g(n) for all large n. f(n) =Ω(g(n)) means that f(n) is lower bounded by a constant multiple of g(n) for all large n. f(n) = Θ(g(n)) means that f(n) has the same asymptotic growth as g(n) up to multiplication by constants. 10
11 Time Complexity of Algorithms 11
12 Complexity Example def bubble_sort(list) list = list.dup # make copy of input for i in 0..(list.length-2) do for j in 0..(list.length - i - 2) do list[j], list[j + 1] = list[j + 1], list[j] if list[j + 1] < list[j] end end return list end 12
13 Nested For Loops for i in 0..(list.length-2) do # number of iterations: n-1 for j in 0..(list.length - i - 2) do # number of itns: n-1, n-2,..., 1 list[j], list[j + 1] = list[j + 1], list[j] if list[j + 1] < list[j] end end Let n = list.length. Then the two nested loops take (n-1 + n ) O(1) = (n(n-1)/2) O(1) = O(n 2 ) time. 13
14 Total Time Complexity def bubble_sort(list) # O(1) for parameter assignment list = list.dup # O(n) for i in 0..(list.length-2) do # O(n 2 ) for j in 0..(list.length - i - 2) do list[j], list[j + 1] = list[j + 1], list[j] if list[j + 1] < list[j] end end return list # O(1) end # O(1) + O(n) + O(n 2 ) + O(1) = O(n 2 ) 14
15 Sequences and Summations 15
16 Sequences A sequence is a function from a subset of the set of integers (such as {0,1,2,...} or {1,2,3,...}) to some set S. We use the notation a n to denote the image of the integer n. We call a n a term of the sequence. We use the notations {a n } or (a n ) to denote sequences. 16
17 Example: Fibonacci Sequence Recall that the Fibonacci sequence is defined by the initial conditions: f 0 =0 and f 1 =1 and the recurrence relation f n = f n-1 +f n-2 for n >= 2. Hence, {f n } = {0,1,1,2,3,5,8,13,...} 17
18 Sums We use the notations nx k=m a k = a m + a m a n The letter k is called the index of summation. 18
19 Sum of the First n Positive Integers For all n 1, we have P n k=1 k = n(n + 1)/2 We prove this by induction. Let A(n) be the claimed equality. Basis Step: We need to show that A(1) holds. For n = 1, we have P 1 k = 1 = 1(1 + 1)/2. k=1 19
20 Sum of the First n Positive Integers Induction Step: We need to show that 8n 1:[A(n) A(n + 1)] As induction hypothesis, suppose that A(n) holds. Then, n+1 X k=1 k = (n + 1) + = 2(n + 1) 2 nx k= k n(n + 1) 2 = 2n +2+n2 + n 2 (n + 1)(n + 2) = 2 by Induction Hypothesis = n2 +3n +2 2 Therefore, the claim follows by induction on n.
21 Sum of Fibonacci Numbers n Let f 0 = 0 and f 1 = 1 and f n = f n 1 + f n 2 for 2. Then nx k=1 f k = f n+2 1. Induction basis: For n = 1, we have 1X k=1 f k = 1 = (1 + 1) 1=f 1 + f 2 1=f
22 Sum of Fibonacci Numbers Let A(n) be the claimed equality. Induction Step: We need to show that 8n 1:[A(n) A(n + 1)] As induction hypothesis, suppose that A(n) holds. Then, n+1 X k=1 nx f k = f n+1 + k=1 f k = f n+1 + f n+2 1 by Induction Hypothesis = f n+3 1 by definition Therefore, the claim follows by induction on n. 22
23 Weak and Strong Induction 23
24 Motivation Induction is an axiom which allows us to prove that certain properties are true for all positive integers (or for all nonnegative integers, or all integers >= some fixed number) 24
25 Induction Principle Let A(n) be an assertion concerning the integer n. If we want to show that A(n) holds for all positive integer n, we can proceed as follows: Induction basis: Show that the assertion A(1) holds. Induction step: Show that [A(n) A(n+1)] holds for all positive integers n. 25
26 Strong Induction Principle Let A(n) be the assertion concerning the integer n. If we want to prove it for all n >= 1, we can do the following: Induction basis: Show that A(1) is true. Induction step: Show that [(A(1)... A(n)) A(n+1)] holds for all n >=1. 26
27 Weak or Strong Induction? You might wonder which form of induction you should use. Generally, you use strong induction when assuming only that the assertion A(n) holds does not seem to help in proving A(n+1). Strong induction can make the induction step easier to prove in such cases. On the other hand, weak induction is sometimes more straightforward to use (so it is preferred when the induction step can be proved by assuming A(n) alone). 27
28 Example (1/4) Theorem: For all positive integers n, we have that 12 divides n 4 -n 2. Weak or strong induction? Unclear. So let s try weak induction. 28
29 Example (2/4) Let s try to prove it by weak induction: Base Step: Since = 1-1 = 0 = 0*12 is divisible by 12, the claim is true for n=1. Inductive Step: Let us assume that 12 divides n 4 -n 2. Our goal is to show that this implies that 12 divides (n+1) 4 -(n+1) 2 Since (n+1) 4 -(n+1) 2 = n 4 +4n 3 +6n 2 +4n+1 - (n 2 +2n+1), we get (n+1) 4 -(n+1) 2 = n 4 - n 2 + 4n 3 +6n 2 +2n. By assumption 12 divides n 4 - n 2. Why does 12 divide 4n 3 +6n 2 +2n? You don t know? I don t know either. At least, it is not obvious. 29
30 Example (3/4) Let us try to prove it by strong induction. Perhaps we can show that A(n) implies A(n+6). Base case: n = 1: = 1-1 = 0 = 0*12 n = 2: = 16-4 = 12 = 1*12 n = 3: = 81 9 = 72 = 6*12 n = 4: = = 240 = 20 * 12 n = 5: = = 600 = 50*12 n = 6: = = 1260 = 105*12 Thus, the claim is true for n=1,...,6. 30
31 Example (4/4) Let n>=6. Let us assume that 12 divides m 4 m 2 for 1 m n. Our goal is to show that 12 divides (n+1) 4 (n+1) 2. For simplicity, let m = n+1-6=n-5. By assumption, 12 divides m 4 m 2. (n + 1) 4 (n + 1) 2 =(m + 6) 4 (m + 6) 2 = m m m m (m m + 36) =(m 4 m 2 ) + 24m m m = 12a + 24m m m = 12(a +2m m m + 105) for some integer a. Thus, the claim follows by strong induction. 31
32 Example Theorem: For all positive integers n, we have (2n-1) = n 2 Proof. We prove this by induction on n. Let A(n) be the assertion of the theorem. Induction basis: Since 1 = 1 2, it follows that A(1) holds. Induction step: Suppose that A(n) holds. Then (2n-1)+(2n+1) = n 2 +2n+1 = (n+1) 2 holds. In other words, A(n) implies A(n+1). Therefore, the claim follows by induction on n. 32
33 Inductively Defined Sets and Structural Induction 33
34 Inductively Defined Sets An inductive definition of a set S has the following form: (a) Basis: Specify one or more initial elements of S. (b) Induction: Give one or more rules for constructing new elements of S from old elements of S. (c) Closure: The set S consists of exactly the elements that can be obtained by starting with the initial elements of S and applying the rules for constructing new elements of S. The closure condition is usually omitted, since it is always assumed in inductive definitions. 34
35 Example 1 Let S be the set defined as follows: Basis: 0 S Induction: If n S, then 2n+1 S. Can you describe the set S? S = {0,1,3,7,15,31,... } = { 2 n -1 n a nonnegative integer } since 2 0-1=0 and 2 n+1-1 = 2(2 n -1)+1 35
36 Example 2: Binary Trees We can define the set B of binary trees over an alphabet A as follows: Basis: B. Induction: If L, R B and x A, then L,x,R B. Example:,1, // tree with one node (1) Example:,1,, r,,2, // tree with root r and two children (1 and 2). 36
37 Recursively Defined Functions Suppose we have a function with the set of nonnegative integers as its domain. We can specify the function as follows: Basis step: Specify the value of the function at 0 Inductive step: Give a rule for finding its value at an integer from its values at smaller integers. This is called a recursive or inductive definition. 37
38 Example 1: Factorial Function We can define the factorial function n as follows: Base step: 0 = 1 Inductive step: n = n (n-1) 38
39 Example 2: Ackermann Function A(m, n) = 8 >< n +1 ifm =0, A(m 1, 1) if m>0 and n =0, >: A(m 1,A(m, n 1)) if m>0 and n>0 The Ackermann function has particular significance in computability theory. The values of A(m,n) grow very, very quickly. Why does the recursion terminate? Lexicographically order the pairs (m,n). So (m,n) < (m,n ) iff m<m or (m=m and n<n ). Note that arguments used in the RHS are lexicographically smaller than the arguments in the LHS. Thus, eventually we need to end up in case m=0, though it might take an extremely long time. 39
40 Structural Induction In structural induction, the proof of the assertion that every element of an inductively defined set S has a certain property P proceeds by showing that Basis: Every element in the basis of the definition of S satisfies the property P. Induction: Assuming that every argument of a constructor has property P, show that the constructed element has the property P. 40
41 Example 1: Binary Trees Recall that the set B of binary trees over an alphabet A is defined as follows: Basis: B. Induction: If L, R B and x A, then L,x,R B. We can now prove that every binary tree has a property P by arguing that Basis: P( ) is true. Induction: For all binary trees L and R and x in A, if P(L) and P(R), then P( L,x,R ). 41
42 Example: Binary Trees - The Number of Leaves Let f: B -> N be the function defined by f(hi) = 0 ( 1 if L = R = hi f(hl, x, Ri) = f(l)+f(r) otherwise Theorem: Let T in B be a binary tree. Then f(t) yields the number of leaves of T. 42
43 Binary Trees - The Number of Leaves Theorem: Let T in B be a binary tree. Then f(t) yields the number of leaves of T. Proof: By structural induction on T. Basis: The empty tree has no leaves, so f( ) = 0 is correct. Induction: Let L,R be trees in B, x in A. Suppose that f(l) and f(r) denotes the number of leaves of L and R, respectively. If L=R=, then L,x,R> =,x, has one leaf, namely x, so f(,x, )=1 is correct. 43
44 Binary Trees - The Number of Leaves (Cont.) If L and R are not both empty, then the number of leaves of the tree L,x,R is equal to the number of leaves of L plus the number of leaves of R. Hence, by induction hypothesis, we get as claimed. This completes the proof. f( L,x,R ) = f(r)+f(l) 44
45 Example 2: Full Binary Trees The set of full binary trees can be defined as follows: Basis: There is a full binary tree consisting of a single vertex r Induction: If T 1 and T 2 are disjoint full binary trees and r in A is a node, then <T 1, r, T 2 > is a full binary tree with root r and left subtree T 1 and right subtree T 2. The difference between binary trees and full binary trees is in the basis step. A binary tree is full if and only if each node is either a leaf or has precisely two children. 45
46 Small Full Binary Trees Level 0: Level 1: not full Level 2: 46
47 Height of a Full Binary Tree Let T be a full binary tree over an alphabet A. We define the height h(t) of a full binary tree as follows: Basis: For r in A, we define h(r) = 0; that is, the height of a full binary tree with just a single node is 0. Induction: If L and R are full binary trees and r in A, then the tree <L,r,R> has height h( <L,r,R> ) = 1 + max( h(l), h(r) ). 47
48 Number of Nodes of a Full Binary Tree Let n(t) denote the number of nodes of a full binary tree over an alphabet A. Then Basis: For r in A, we have n(r)=1. Induction: If L and R are full binary trees and r in A, then the number of nodes of <L,r,R> is given by n(<l,r,r>) = 1+n(L)+n(R). 48
49 Example of Structural Induction Theorem: Let T be a full binary tree over an alphabet A. Then we have n(t) <= 2 h(t)+1-1. Proof: By structural induction. Basis step: For r in A, we have n(r)=1 and h(r)=0, therefore, we have n(r) = 1 <= 2 (0+1) -1 = 2 h(r)+1-1, as claimed. Inductive step: Suppose that L and R are full binary trees that satisfy n(l) <= 2 h(l)+1-1 and n(r) <= 2 h(r)+1-1. Then the tree T=<L,r,R> satisfies: n(t) = 1 + n(l) + n(r) <= h(l) h(r)+1-1, by I.H. <= 2 max(2 h(l)+1, 2 h(r)+1 )-1, since a+b <= 2max(a,b) = 2. 2 max(h(l),h(r))+1-1=2. 2 h(t) -1 = 2 h(t)
50 Solving Recurrences Solving a recurrence system means finding a closed form expression for the n-th term. At this point, you need to be able to solve recurrences - by using the iterative method, and - by inspecting, guessing, and verifying a solution. For verification, use proof-by-induction 50
51 Counting 51
52 Counting Rules and Principles Below are the counting rules and principles we cover in class. Refer the lecture slides on Counting for definitions and examples. Product rule Sum rule Subtraction rule, principle of inclusion-exclusion Pigeonhole principle Permutations and combinations Binomial theorem and identities Pascal s identity and Pascal s triangle 52
CSCE 222 Discrete Structures for Computing. Review for the Final. Hyunyoung Lee
CSCE 222 Discrete Structures for Computing Review for the Final! Hyunyoung Lee! 1 Final Exam Section 501 (regular class time 8:00am) Friday, May 8, starting at 1:00pm in our classroom!! Section 502 (regular
More informationReview 3. Andreas Klappenecker
Review 3 Andreas Klappenecker Final Exam Friday, May 4, 2012, starting at 12:30pm, usual classroom Topics Topic Reading Algorithms and their Complexity Chapter 3 Logic and Proofs Chapter 1 Logic and Proofs
More informationReview 1. Andreas Klappenecker
Review 1 Andreas Klappenecker Summary Propositional Logic, Chapter 1 Predicate Logic, Chapter 1 Proofs, Chapter 1 Sets, Chapter 2 Functions, Chapter 2 Sequences and Sums, Chapter 2 Asymptotic Notations,
More informationCSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee
CSCE 222 Discrete Structures for Computing Sequences and Summations Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1 Sequences 2 Sequences A sequence is a function from a subset of the set of
More informationBinomial Coefficient Identities/Complements
Binomial Coefficient Identities/Complements CSE21 Fall 2017, Day 4 Oct 6, 2017 https://sites.google.com/a/eng.ucsd.edu/cse21-fall-2017-miles-jones/ permutation P(n,r) = n(n-1) (n-2) (n-r+1) = Terminology
More informationInduction and Recursion
. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Induction and Recursion
More informationCSCE 222 Discrete Structures for Computing. Proof by Induction. Dr. Hyunyoung Lee. !!!!!! Based on slides by Andreas Klappenecker
CSCE 222 Discrete Structures for Computing Proof by Induction Dr. Hyunyoung Lee Based on slides by Andreas Klappenecker 1 Motivation Induction is an axiom which allows us to prove that certain properties
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 informationChapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms
1 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms 2 Section 5.1 3 Section Summary Mathematical Induction Examples of
More informationMath 324 Summer 2012 Elementary Number Theory Notes on Mathematical Induction
Math 4 Summer 01 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If
More informationAlgorithm Analysis Recurrence Relation. Chung-Ang University, Jaesung Lee
Algorithm Analysis Recurrence Relation Chung-Ang University, Jaesung Lee Recursion 2 Recursion 3 Recursion in Real-world Fibonacci sequence = + Initial conditions: = 0 and = 1. = + = + = + 0, 1, 1, 2,
More informationInduction and recursion. Chapter 5
Induction and recursion Chapter 5 Chapter Summary Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms Mathematical Induction Section 5.1
More informationWith Question/Answer Animations
Chapter 5 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 informationProof Techniques (Review of Math 271)
Chapter 2 Proof Techniques (Review of Math 271) 2.1 Overview This chapter reviews proof techniques that were probably introduced in Math 271 and that may also have been used in a different way in Phil
More informationIn-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2
In-Class Soln 1 Let f(n) be an always positive function and let g(n) = f(n) log n. Show that f(n) = o(g(n)) CS 361, Lecture 4 Jared Saia University of New Mexico For any positive constant c, we want to
More informationAnalysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort
Analysis of Algorithms I: Asymptotic Notation, Induction, and MergeSort Xi Chen Columbia University We continue with two more asymptotic notation: o( ) and ω( ). Let f (n) and g(n) are functions that map
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 10, 2018 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. 1 /
More informationMATH 324 Summer 2011 Elementary Number Theory. Notes on Mathematical Induction. Recall the following axiom for the set of integers.
MATH 4 Summer 011 Elementary Number Theory Notes on Mathematical Induction Principle of Mathematical Induction Recall the following axiom for the set of integers. Well-Ordering Axiom for the Integers If
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 4 - Jan. 14, 2019 CLRS 1.1, 1.2, 2.2, 3.1, 4.3, 4.5 University of Manitoba Picture is from the cover of the textbook CLRS. COMP
More informationFall 2017 Test II review problems
Fall 2017 Test II review problems Dr. Holmes October 18, 2017 This is a quite miscellaneous grab bag of relevant problems from old tests. Some are certainly repeated. 1. Give the complete addition and
More informationICS141: Discrete Mathematics for Computer Science I
ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by
More information3.1 Asymptotic notation
3.1 Asymptotic notation The notations we use to describe the asymptotic running time of an algorithm are defined in terms of functions whose domains are the set of natural numbers N = {0, 1, 2,... Such
More informationChapter 0: Preliminaries
Chapter 0: Preliminaries Adam Sheffer March 28, 2016 1 Notation This chapter briefly surveys some basic concepts and tools that we will use in this class. Graduate students and some undergrads would probably
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 informationWritten Homework #1: Analysis of Algorithms
Written Homework #1: Analysis of Algorithms CIS 121 Fall 2016 cis121-16fa-staff@googlegroups.com Due: Thursday, September 15th, 2015 before 10:30am (You must submit your homework online via Canvas. A paper
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 informationDiscrete Structures for Computer Science: Counting, Recursion, and Probability
Discrete Structures for Computer Science: Counting, Recursion, and Probability Michiel Smid School of Computer Science Carleton University Ottawa, Ontario Canada michiel@scs.carleton.ca December 18, 2017
More informationi=1 i B[i] B[i] + A[i, j]; c n for j n downto i + 1 do c n i=1 (n i) C[i] C[i] + A[i, j]; c n
Fundamental Algorithms Homework #1 Set on June 25, 2009 Due on July 2, 2009 Problem 1. [15 pts] Analyze the worst-case time complexity of the following algorithms,and give tight bounds using the Theta
More informationQuiz 3 Reminder and Midterm Results
Quiz 3 Reminder and Midterm Results Reminder: Quiz 3 will be in the first 15 minutes of Monday s class. You can use any resources you have during the quiz. It covers all four sections of Unit 3. It has
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Associate Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu Based
More informationINDUCTION AND RECURSION. Lecture 7 - Ch. 4
INDUCTION AND RECURSION Lecture 7 - Ch. 4 4. Introduction Any mathematical statements assert that a property is true for all positive integers Examples: for every positive integer n: n!
More informationRecursion. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry. Fall 2007
Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry Fall 2007 1 / 47 Computer Science & Engineering 235 to Discrete Mathematics Sections 7.1-7.2 of Rosen Recursive Algorithms 2 / 47 A recursive
More informationCSC 344 Algorithms and Complexity. Proof by Mathematical Induction
CSC 344 Algorithms and Complexity Lecture #1 Review of Mathematical Induction Proof by Mathematical Induction Many results in mathematics are claimed true for every positive integer. Any of these results
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 informationAlgorithms Design & Analysis. Analysis of Algorithm
Algorithms Design & Analysis Analysis of Algorithm Review Internship Stable Matching Algorithm 2 Outline Time complexity Computation model Asymptotic notions Recurrence Master theorem 3 The problem of
More informationDiscrete Mathematics. Spring 2017
Discrete Mathematics Spring 2017 Previous Lecture Principle of Mathematical Induction Mathematical Induction: Rule of Inference Mathematical Induction: Conjecturing and Proving Mathematical Induction:
More informationHomework 1 Submission
Homework Submission Sample Solution; Due Date: Thursday, May 4, :59 pm Directions: Your solutions should be typed and submitted as a single pdf on Gradescope by the due date. L A TEX is preferred but not
More informationMA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3
MA008 p.1/37 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 3 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/37 Exercise 1 (from LN 2) Asymptotic Notation When constants appear in exponents
More informationCS1800: Mathematical Induction. Professor Kevin Gold
CS1800: Mathematical Induction Professor Kevin Gold Induction: Used to Prove Patterns Just Keep Going For an algorithm, we may want to prove that it just keeps working, no matter how big the input size
More informationCounting. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee
Counting Mukulika Ghosh Fall 2018 Based on slides by Dr. Hyunyoung Lee Counting Counting The art of counting is known as enumerative combinatorics. One tries to count the number of elements in a set (or,
More informationLecture 1: Asymptotic Complexity. 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole.
Lecture 1: Asymptotic Complexity 1 These slides include material originally prepared by Dr.Ron Cytron, Dr. Jeremy Buhler, and Dr. Steve Cole. Announcements TA office hours officially start this week see
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 information1 Basic Combinatorics
1 Basic Combinatorics 1.1 Sets and sequences Sets. A set is an unordered collection of distinct objects. The objects are called elements of the set. We use braces to denote a set, for example, the set
More informationIntroduction to Algorithms
Introduction to Algorithms (2 nd edition) by Cormen, Leiserson, Rivest & Stein Chapter 3: Growth of Functions (slides enhanced by N. Adlai A. DePano) Overview Order of growth of functions provides a simple
More informationAnalysis of Algorithms - Using Asymptotic Bounds -
Analysis of Algorithms - Using Asymptotic Bounds - Andreas Ermedahl MRTC (Mälardalens Real-Time Research Center) andreas.ermedahl@mdh.se Autumn 004 Rehersal: Asymptotic bounds Gives running time bounds
More informationChapter 11 - Sequences and Series
Calculus and Analytic Geometry II Chapter - Sequences and Series. Sequences Definition. A sequence is a list of numbers written in a definite order, We call a n the general term of the sequence. {a, a
More informationContents. Counting Methods and Induction
Contents Counting Methods and Induction Lesson 1 Counting Strategies Investigations 1 Careful Counting... 555 Order and Repetition I... 56 3 Order and Repetition II... 569 On Your Own... 573 Lesson Counting
More informationAsymptotic Analysis 1
Asymptotic Analysis 1 Last week, we discussed how to present algorithms using pseudocode. For example, we looked at an algorithm for singing the annoying song 99 Bottles of Beer on the Wall for arbitrary
More informationAdvanced Counting Techniques. Chapter 8
Advanced Counting Techniques Chapter 8 Chapter Summary Applications of Recurrence Relations Solving Linear Recurrence Relations Homogeneous Recurrence Relations Nonhomogeneous Recurrence Relations Divide-and-Conquer
More informationModule 1: Analyzing the Efficiency of Algorithms
Module 1: Analyzing the Efficiency of Algorithms Dr. Natarajan Meghanathan Professor of Computer Science Jackson State University Jackson, MS 39217 E-mail: natarajan.meghanathan@jsums.edu What is an Algorithm?
More informationare the q-versions of n, n! and . The falling factorial is (x) k = x(x 1)(x 2)... (x k + 1).
Lecture A jacques@ucsd.edu Notation: N, R, Z, F, C naturals, reals, integers, a field, complex numbers. p(n), S n,, b(n), s n, partition numbers, Stirling of the second ind, Bell numbers, Stirling of the
More informationCS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms
CS 4407 Algorithms Lecture 2: Iterative and Divide and Conquer Algorithms Prof. Gregory Provan Department of Computer Science University College Cork 1 Lecture Outline CS 4407, Algorithms Growth Functions
More informationReview for Midterm 1. Andreas Klappenecker
Review for Midterm 1 Andreas Klappenecker Topics Chapter 1: Propositional Logic, Predicate Logic, and Inferences Rules Chapter 2: Sets, Functions (Sequences), Sums Chapter 3: Asymptotic Notations and Complexity
More informationNotes on induction proofs and recursive definitions
Notes on induction proofs and recursive definitions James Aspnes December 13, 2010 1 Simple induction Most of the proof techniques we ve talked about so far are only really useful for proving a property
More informationdata structures and algorithms lecture 2
data structures and algorithms 2018 09 06 lecture 2 recall: insertion sort Algorithm insertionsort(a, n): for j := 2 to n do key := A[j] i := j 1 while i 1 and A[i] > key do A[i + 1] := A[i] i := i 1 A[i
More informationP, NP, NP-Complete, and NPhard
P, NP, NP-Complete, and NPhard Problems Zhenjiang Li 21/09/2011 Outline Algorithm time complicity P and NP problems NP-Complete and NP-Hard problems Algorithm time complicity Outline What is this course
More informationLecture 2. More Algorithm Analysis, Math and MCSS By: Sarah Buchanan
Lecture 2 More Algorithm Analysis, Math and MCSS By: Sarah Buchanan Announcements Assignment #1 is posted online It is directly related to MCSS which we will be talking about today or Monday. There are
More informationWhen we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:
CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe
More informationRecurrences COMP 215
Recurrences COMP 215 Analysis of Iterative Algorithms //return the location of the item matching x, or 0 if //no such item is found. index SequentialSearch(keytype[] S, in, keytype x) { index location
More informationPUTNAM TRAINING NUMBER THEORY. Exercises 1. Show that the sum of two consecutive primes is never twice a prime.
PUTNAM TRAINING NUMBER THEORY (Last updated: December 11, 2017) Remark. This is a list of exercises on Number Theory. Miguel A. Lerma Exercises 1. Show that the sum of two consecutive primes is never twice
More informationAnalysis of Algorithms
September 29, 2017 Analysis of Algorithms CS 141, Fall 2017 1 Analysis of Algorithms: Issues Correctness/Optimality Running time ( time complexity ) Memory requirements ( space complexity ) Power I/O utilization
More informationDivide and Conquer CPE 349. Theresa Migler-VonDollen
Divide and Conquer CPE 349 Theresa Migler-VonDollen Divide and Conquer Divide and Conquer is a strategy that solves a problem by: 1 Breaking the problem into subproblems that are themselves smaller instances
More informationCS Non-recursive and Recursive Algorithm Analysis
CS483-04 Non-recursive and Recursive Algorithm Analysis Instructor: Fei Li Room 443 ST II Office hours: Tue. & Thur. 4:30pm - 5:30pm or by appointments lifei@cs.gmu.edu with subject: CS483 http://www.cs.gmu.edu/
More informationHomework Assignment 1 Solutions
MTAT.03.286: Advanced Methods in Algorithms Homework Assignment 1 Solutions University of Tartu 1 Big-O notation For each of the following, indicate whether f(n) = O(g(n)), f(n) = Ω(g(n)), or f(n) = Θ(g(n)).
More informationPreparing for the CS 173 (A) Fall 2018 Midterm 1
Preparing for the CS 173 (A) Fall 2018 Midterm 1 1 Basic information Midterm 1 is scheduled from 7:15-8:30 PM. We recommend you arrive early so that you can start exactly at 7:15. Exams will be collected
More informationMath 10850, fall 2017, University of Notre Dame
Math 10850, fall 2017, University of Notre Dame Notes on first exam September 22, 2017 The key facts The first midterm will be on Thursday, September 28, 6.15pm-7.45pm in Hayes-Healy 127. What you need
More informationSome Review Problems for Exam 3: Solutions
Math 3355 Fall 018 Some Review Problems for Exam 3: Solutions I thought I d start by reviewing some counting formulas. Counting the Complement: Given a set U (the universe for the problem), if you want
More informationAdministrivia. COMP9020 Lecture 7 Session 2, 2017 Induction and Recursion. Lecture 6 recap. Lecture 6 recap
Administrivia COMP9020 Lecture 7 Session 2, 2017 Induction and Recursion Guidelines for good mathematical writing Assignment 1 Solutions now available; marks available soon Assignment 2 available on Saturday,
More informationFall 2016 Test 1 with Solutions
CS3510 Design & Analysis of Algorithms Fall 16 Section B Fall 2016 Test 1 with Solutions Instructor: Richard Peng In class, Friday, Sep 9, 2016 Do not open this quiz booklet until you are directed to do
More informationRecommended readings: Description of Quicksort in my notes, Ch7 of your CLRS text.
Chapter 1 Quicksort 1.1 Prerequisites You need to be familiar with the divide-and-conquer paradigm, standard notations for expressing the time-complexity of an algorithm, like the big-oh, big-omega notations.
More informationMA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2
MA008 p.1/36 MA008/MIIZ01 Design and Analysis of Algorithms Lecture Notes 2 Dr. Markus Hagenbuchner markus@uow.edu.au. MA008 p.2/36 Content of lecture 2 Examples Review data structures Data types vs. data
More informationMore Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018
CS 61B More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018 Here is a review of some formulas that you will find useful when doing asymptotic analysis. ˆ N i=1 i = 1 + 2 + 3 + 4 + + N = N(N+1)
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 informationData Structures and Algorithms Running time and growth functions January 18, 2018
Data Structures and Algorithms Running time and growth functions January 18, 2018 Measuring Running Time of Algorithms One way to measure the running time of an algorithm is to implement it and then study
More informationWhen we use asymptotic notation within an expression, the asymptotic notation is shorthand for an unspecified function satisfying the relation:
CS 124 Section #1 Big-Oh, the Master Theorem, and MergeSort 1/29/2018 1 Big-Oh Notation 1.1 Definition Big-Oh notation is a way to describe the rate of growth of functions. In CS, we use it to describe
More informationModels of Computation,
Models of Computation, 2010 1 Induction We use a lot of inductive techniques in this course, both to give definitions and to prove facts about our semantics So, it s worth taking a little while to set
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 informationDiscrete Mathematics. Spring 2017
Discrete Mathematics Spring 2017 Previous Lecture Principle of Mathematical Induction Mathematical Induction: rule of inference Mathematical Induction: Conjecturing and Proving Climbing an Infinite Ladder
More informationMATH 802: ENUMERATIVE COMBINATORICS ASSIGNMENT 2
MATH 80: ENUMERATIVE COMBINATORICS ASSIGNMENT KANNAPPAN SAMPATH Facts Recall that, the Stirling number S(, n of the second ind is defined as the number of partitions of a [] into n non-empty blocs. We
More informationLecture 1: Asymptotics, Recurrences, Elementary Sorting
Lecture 1: Asymptotics, Recurrences, Elementary Sorting Instructor: Outline 1 Introduction to Asymptotic Analysis Rate of growth of functions Comparing and bounding functions: O, Θ, Ω Specifying running
More informationMid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010
Mid-term Exam Answers and Final Exam Study Guide CIS 675 Summer 2010 Midterm Problem 1: Recall that for two functions g : N N + and h : N N +, h = Θ(g) iff for some positive integer N and positive real
More informationLecture 12 : Recurrences DRAFT
CS/Math 240: Introduction to Discrete Mathematics 3/1/2011 Lecture 12 : Recurrences Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last few classes we talked about program correctness. We
More information1. Determine (with proof) the number of ordered triples (A 1, A 2, A 3 ) of sets which satisfy
UT Putnam Prep Problems, Oct 19 2016 I was very pleased that, between the whole gang of you, you solved almost every problem this week! Let me add a few comments here. 1. Determine (with proof) the number
More information0 Sets and Induction. Sets
0 Sets and Induction Sets A set is an unordered collection of objects, called elements or members of the set. A set is said to contain its elements. We write a A to denote that a is an element of the set
More informationCSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.
CSI 2101- Mathematical Induction Many statements assert that a property of the form P(n) is true for all integers n. Examples: For every positive integer n: n! n n Every set with n elements, has 2 n Subsets.
More informationCS473 - Algorithms I
CS473 - Algorithms I Lecture 2 Asymptotic Notation 1 O-notation: Asymptotic upper bound f(n) = O(g(n)) if positive constants c, n 0 such that 0 f(n) cg(n), n n 0 f(n) = O(g(n)) cg(n) f(n) Asymptotic running
More informationSome Review Problems for Exam 3: Solutions
Math 3355 Spring 017 Some Review Problems for Exam 3: Solutions I thought I d start by reviewing some counting formulas. Counting the Complement: Given a set U (the universe for the problem), if you want
More informationComputational Complexity. This lecture. Notes. Lecture 02 - Basic Complexity Analysis. Tom Kelsey & Susmit Sarkar. Notes
Computational Complexity Lecture 02 - Basic Complexity Analysis Tom Kelsey & Susmit Sarkar School of Computer Science University of St Andrews http://www.cs.st-andrews.ac.uk/~tom/ twk@st-andrews.ac.uk
More informationGrade 11/12 Math Circles Fall Nov. 5 Recurrences, Part 2
1 Faculty of Mathematics Waterloo, Ontario Centre for Education in Mathematics and Computing Grade 11/12 Math Circles Fall 2014 - Nov. 5 Recurrences, Part 2 Running time of algorithms In computer science,
More informationCDM Combinatorial Principles
CDM Combinatorial Principles 1 Counting Klaus Sutner Carnegie Mellon University Pigeon Hole 22-in-exclusion 2017/12/15 23:16 Inclusion/Exclusion Counting 3 Aside: Ranking and Unranking 4 Counting is arguably
More informationcse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska
cse547, math547 DISCRETE MATHEMATICS Professor Anita Wasilewska LECTURE 1 INTRODUCTION Course Web Page www.cs.stonybrook.edu/ cse547 The webpage contains: detailed lectures notes slides; very detailed
More informationCSCE 750 Final Exam Answer Key Wednesday December 7, 2005
CSCE 750 Final Exam Answer Key Wednesday December 7, 2005 Do all problems. Put your answers on blank paper or in a test booklet. There are 00 points total in the exam. You have 80 minutes. Please note
More informationLecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018
CS17 Integrated Introduction to Computer Science Klein Contents Lecture 17: Trees and Merge Sort 10:00 AM, Oct 15, 2018 1 Tree definitions 1 2 Analysis of mergesort using a binary tree 1 3 Analysis of
More informationComplete Induction and the Well- Ordering Principle
Complete Induction and the Well- Ordering Principle Complete Induction as a Rule of Inference In mathematical proofs, complete induction (PCI) is a rule of inference of the form P (a) P (a + 1) P (b) k
More informationSection Summary. Sequences. Recurrence Relations. Summations. Examples: Geometric Progression, Arithmetic Progression. Example: Fibonacci Sequence
Section 2.4 Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations Introduction Sequences are ordered lists of elements.
More informationRecursion: Introduction and Correctness
Recursion: Introduction and Correctness CSE21 Winter 2017, Day 7 (B00), Day 4-5 (A00) January 25, 2017 http://vlsicad.ucsd.edu/courses/cse21-w17 Today s Plan From last time: intersecting sorted lists and
More informationHomework #2 Solutions Due: September 5, for all n N n 3 = n2 (n + 1) 2 4
Do the following exercises from the text: Chapter (Section 3):, 1, 17(a)-(b), 3 Prove that 1 3 + 3 + + n 3 n (n + 1) for all n N Proof The proof is by induction on n For n N, let S(n) be the statement
More informationAdvanced Counting Techniques
. All rights reserved. Authorized only for instructor use in the classroom. No reproduction or further distribution permitted without the prior written consent of McGraw-Hill Education. Advanced Counting
More informationCSCE 222 Discrete Structures for Computing. Review for Exam 1. Dr. Hyunyoung Lee !!!
CSCE 222 Discrete Structures for Computing Review for Exam 1 Dr. Hyunyoung Lee 1 Topics Propositional Logic (Sections 1.1, 1.2 and 1.3) Predicate Logic (Sections 1.4 and 1.5) Rules of Inferences and Proofs
More informationProof by Induction. Andreas Klappenecker
Proof by Induction Andreas Klappenecker 1 Motivation Induction is an axiom which allows us to prove that certain properties are true for all positive integers (or for all nonnegative integers, or all integers
More information