Data Structures and Algorithms Discrete Math Review.

Slides:



Advertisements
Similar presentations
COUNTING AND PROBABILITY
Advertisements

Recursively Defined Functions
Induction and recursion
Fall 2002CMSC Discrete Structures1 Permutations How many ways are there to pick a set of 3 people from a group of 6? There are 6 choices for the.
Kavita Math231 Recursion and Iteration. Kavita Math231 We use Recursion when we have to perform a complex task that can be broken into the several subtasks.
Math for Elementary Teachers
CSE115/ENGR160 Discrete Mathematics 04/17/12
CSE115/ENGR160 Discrete Mathematics 02/22/11 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 02/21/12
1 Section 3.2 Sequences and Summations. 2 Sequence Function from a subset of Z (usually the set beginning with 1 or 0) to a set S a n denotes the image.
Recursive Definitions Rosen, 3.4 Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Induction and recursion
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Elementary Counting Techniques & Combinatorics Martina Litschmannová K210.
Basic Concepts of Algebra
CS355 - Theory of Computation Lecture 2: Mathematical Preliminaries.
1 © 2010 Pearson Education, Inc. All rights reserved 10.1 DEFINITION OF A SEQUENCE An infinite sequence is a function whose domain is the set of positive.
Discrete Mathematics CS 2610 March 26, 2009 Skip: structural induction generalized induction Skip section 4.5.
Induction and recursion
Sequences and Summations
Discrete Mathematics, 1st Edition Kevin Ferland
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Chapter 6 With Question/Answer Animations 1. Chapter Summary The Basics of Counting The Pigeonhole Principle Permutations and Combinations Binomial Coefficients.
Slide 7- 1 Copyright © 2006 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Discrete Mathematics Math Review. Math Review: Exponents, logarithms, polynomials, limits, floors and ceilings* * This background review is useful for.
Fall 2002CMSC Discrete Structures1 One, two, three, we’re… Counting.
CSE 221: Algorithms and Data Structures Lecture #10 Counting: Easy as 1, 2, C(3,1) Steve Wolfman 2009W1 1.
Dr. Eng. Farag Elnagahy Office Phone: King ABDUL AZIZ University Faculty Of Computing and Information Technology CPCS 222.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesFunctions.
Data Structures and Algorithms Week #1. Data Structures and Algorithms This course represents the foundation of your Computer Science education. This.
Sequences and Summations
P.1 Real Numbers. 2 What You Should Learn Represent and classify real numbers. Order real numbers and use inequalities. Find the absolute values of real.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Set A formal collection of objects, which can be anything May be finite or infinite Can be defined by: – Listing the elements – Drawing a picture – Writing.
Counting CSC-2259 Discrete Structures Konstantin Busch - LSU1.
April 14, 2015Applied Discrete Mathematics Week 10: Equivalence Relations 1 Properties of Relations Definition: A relation R on a set A is called transitive.
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
Functions Section 2.3. Section Summary Definition of a Function. – Domain, Cdomain – Image, Preimage Injection, Surjection, Bijection Inverse Function.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Discrete Mathematics R. Johnsonbaugh
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
CompSci 102 Discrete Math for Computer Science March 1, 2012 Prof. Rodger Slides modified from Rosen.
Counting Discrete Mathematics. Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter passwords are there?”
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
Sets Definition: 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.
1 CS 140 Discrete Mathematics Combinatorics And Review Notes.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
Discrete Mathematics Lecture # 22 Recursion.  First of all instead of giving the definition of Recursion we give you an example, you already know the.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
2/24/20161 One, two, three, we’re… Counting. 2/24/20162 Basic Counting Principles Counting problems are of the following kind: “How many different 8-letter.
Chapter 5. Section 5.1 Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If we can reach.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sequences and Summations.
3/16/20161 … and now for… Sequences. 3/16/20162 Sequences Sequences represent ordered lists of elements. A sequence is defined as a function from a subset.
Chapter 2 1. Chapter Summary Sets The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions and sequences.
Lecture # 20 Sequence & Series
COUNTING Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
CSC-2259 Discrete Structures
COCS DISCRETE STRUCTURES
Discrete Mathematics Lecture#14.
Recursively Defined Functions
Mathematical Induction Recursion
ICS 253: Discrete Structures I
Sequences Overview.
Counting Discrete Mathematics.
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Presentation transcript:

Data Structures and Algorithms Discrete Math Review

Discrete Math review Logarithmic Functions Logarithmic Functions Sets Sets Logic Logic Induction Induction Counting Counting

Sets A set is a collection of individual elements in the domain D. The universal set U contains every element in D. The null set  contains no element. A set is a collection of individual elements in the domain D. The universal set U contains every element in D. The null set  contains no element. If A is a set in the domain D, A must be a subset of the universal set U, denoted as A  U. If A is a set in the domain D, A must be a subset of the universal set U, denoted as A  U. If A consists of some but not all elements, A is then called a proper subset of U, denoted as If A consists of some but not all elements, A is then called a proper subset of U, denoted as A  U. A  U.

Sets A set is a collection of definite and separate objects. A set is a collection of definite and separate objects. The cardinality of a set is the number of elements in the set. The cardinality of a set is the number of elements in the set. A subset of a set is a set comprised of a sub- collection of the elements of the original set. A subset of a set is a set comprised of a sub- collection of the elements of the original set. Example: Consider the set S = {2, 5, 7}. The subsets of S are the sets {2}, {5}, {7}, {2,5}, {2,7}, {5,7}, {2, 5, 7}and {} (the empty set). Example: Consider the set S = {2, 5, 7}. The subsets of S are the sets {2}, {5}, {7}, {2,5}, {2,7}, {5,7}, {2, 5, 7}and {} (the empty set). Fact: If a set has cardinality = n, then the number of subsets = 2 n.

Sets A proper subset of a set is a set comprised of a sub-collection of some, but not all, of the elements of the original set. A proper subset of a set is a set comprised of a sub-collection of some, but not all, of the elements of the original set. Example: Consider the set S = {2, 5, 7}. The proper subsets of S are the sets {2}, {5}, {7}, {2,5}, {2,7}, {5,7} and {} (the empty set). Example: Consider the set S = {2, 5, 7}. The proper subsets of S are the sets {2}, {5}, {7}, {2,5}, {2,7}, {5,7} and {} (the empty set). S = cardinality of 3  2 3  7 ? S = cardinality of 3  2 3  7 ?

Sets There are only two different types of sets: There are only two different types of sets: An Infinite Set is a set that can be placed in a one-to-one correspondence to a proper subset of itself. The Basic Infinite Set is the set of positive whole numbers {1, 2, 3, 4, 5,……}. New Notation: The Basic Infinite Set has cardinality =. The Basic Infinite Set is the set of positive whole numbers {1, 2, 3, 4, 5,……}. New Notation: The Basic Infinite Set has cardinality =. A Finite Set is a set that cannot be placed in a one-to-one correspondence to a proper subset of itself. A Finite Set is a set that cannot be placed in a one-to-one correspondence to a proper subset of itself. Something to think about….2 subsets ? Something to think about….2 subsets ?

Logarithmic Functions Logarithms were invented about 1614 by John Napier. The word logarithm was derived from two Greek words, logos, which means "ratio," and arithmos, which means "number." Logarithms were invented about 1614 by John Napier. The word logarithm was derived from two Greek words, logos, which means "ratio," and arithmos, which means "number." Before calculators and computers were available, common logarithms were used to do certain kinds of calculations Before calculators and computers were available, common logarithms were used to do certain kinds of calculations Growth and decay Growth and decay Big O notation growth of computational complexity Big O notation growth of computational complexity

Logarithmic Functions Logarithms are exponents Logarithms are exponents A logarithmic function is the inverse of an exponential function A logarithmic function is the inverse of an exponential function One way to describe a logarithmic function is to interchange variables in the equation y = a x One way to describe a logarithmic function is to interchange variables in the equation y = a x Thus, x = a y is logarithmic Thus, x = a y is logarithmic

Logarithmic Functions For logarithmic functions we use the notation log a x For logarithmic functions we use the notation log a x Therefore, The following are equivalent. Therefore, The following are equivalent. 1. x = a y ; and 2. y = log a x

Logarithmic Functions Definition of Logarithm Suppose b> 0 and. For n > 0, there is a number p such that log b n = p if and only if b p = n. Suppose b> 0 and. For n > 0, there is a number p such that log b n = p if and only if b p = n. log = ?  2 p = 256 log = ?  2 p = 256 log = ?  10 p = 1000 log = ?  10 p = 1000 log = ?  7 p = 2401 log = ?  7 p = 2401

Logic Examples: Boolean functions: NOT, AND, OR, XOR,... a NOT( a)

Logic Examples: Boolean functions: NOT, AND, OR a NOT( a) a b AND( a, b) a b OR( a, b)

Logic Examples: Boolean functions: XOR, XNOR, NOR a b XOR( a, b) a b XNOR( a, b) a b NOR( a, b)

Logic Boolean Simplification Express F in terms of A and B A B F F = AB + AB  A ( B + B ) = F Using the uniting theorem

Series Arithmetic One common type of series is the arithmetic series (also called an arithmetic progression). Each new term in an arithmetic series is the previous term plus a given number. For example this is an arithmetic series: One common type of series is the arithmetic series (also called an arithmetic progression). Each new term in an arithmetic series is the previous term plus a given number. For example this is an arithmetic series: In this case each term is the previous term plus 3. The difference between each term (the 3 in this case) is called the "common difference" and is generally denoted by the letter d. In this case each term is the previous term plus 3. The difference between each term (the 3 in this case) is called the "common difference" and is generally denoted by the letter d. There are many arithmetic series that have d=3. To specify which series we mean, we need to know one more piece of information: the value of the first term (usually called "a"). There are many arithmetic series that have d=3. To specify which series we mean, we need to know one more piece of information: the value of the first term (usually called "a").

Series Arithmetic If we're given a and d, then, that specifies a unique arithmetic series. All arithmetic series therefore have the following form: a+(a+d)+(a+2d)+(a+3d)+.... If we're given a and d, then, that specifies a unique arithmetic series. All arithmetic series therefore have the following form: a+(a+d)+(a+2d)+(a+3d)+.... So in general we can say that the value of the nth term is a+(n-1)d So in general we can say that the value of the nth term is a+(n-1)d

Series Geometric Another common type of series is the geometric series (also called a geometric progression). In this case, each term is the previous term multiplied by a given number. Another common type of series is the geometric series (also called a geometric progression). In this case, each term is the previous term multiplied by a given number. Here's a geometric series, for example: Here's a geometric series, for example: In this case, each term is the previous term multiplied by 3. The number you multiply by (in this case 3) is called the "common ratio" and is generally denoted by r. In this case, each term is the previous term multiplied by 3. The number you multiply by (in this case 3) is called the "common ratio" and is generally denoted by r. There are many geometric series that have r=3. To specify which series we mean, again we need to know one more piece of information: the value of the first term (usually called "a"). There are many geometric series that have r=3. To specify which series we mean, again we need to know one more piece of information: the value of the first term (usually called "a").

Series Geometric A geometric series is uniquely specified by the values of a and r. Every geometric series has the following form: a+ar+ar 2 +ar Writing the series in this way we can see the formula for working out the value of any term. The first term is just a. The second term is a multiplied by r once. The third term is a multiplied by r twice, and so on. So the nth term must be a multiplied by r (n-1) times, that's ar n-1.

Series Are there others?

The P word….Induction The Principle of Mathematical Induction Suppose we have an assertion P(n) about the positive integers. Suppose we have an assertion P(n) about the positive integers. Then if we show both of (i) and (ii) below, then P(n) is true for all n >= 1. Then if we show both of (i) and (ii) below, then P(n) is true for all n >= 1.  (i). P(1) is true  (ii). For each k >= 1: If P(k) is true, then P(k+1) is true.

The P word….Induction Prove that …+ n = Prove that …+ n = n(n+1) 2 Prove that …+ (2n – 1) = n 2

Counting Product Rule: n ways to do m tasks = nm ways. Product Rule: n ways to do m tasks = nm ways. How many different bit strings are there of length 7? How many different bit strings are there of length 7?

Counting Pigenhole Principle: If N objects are placed into k boxes, then there is at least one box containing at least [N/k] objects. Pigenhole Principle: If N objects are placed into k boxes, then there is at least one box containing at least [N/k] objects. Ten persons were born on the 1 st, 11 th and the 27 th of the months of May, August and November. How many share the exact same birthday? Ten persons were born on the 1 st, 11 th and the 27 th of the months of May, August and November. How many share the exact same birthday? Tells us nothing of the date. Asserts only that one exists!

Counting Permutations and Combinations Permutations: Given that position is important, if one has 4 different objects (e.g. A, B, C and D), how many unique ways can they be placed in 3 positions (e.g. ABD, ACD, BDA, DBA, BAD, ADB, ADC, DCA, DAC, CDA etc.) Permutations: Given that position is important, if one has 4 different objects (e.g. A, B, C and D), how many unique ways can they be placed in 3 positions (e.g. ABD, ACD, BDA, DBA, BAD, ADB, ADC, DCA, DAC, CDA etc.) An ordered arrandement of r elements of a set is called a r-permutation. An ordered arrandement of r elements of a set is called a r-permutation. n! (n – r)! P( n, r )=

Counting Permutations and Combinations Combinations: If one has 4 different objects (e.g. A, B, C and D) how many ways can they be grouped as 2 objects when position does not matter (e.g. AB, AC, AD are correct but DA is not ok as is equal to AD.) Combinations: If one has 4 different objects (e.g. A, B, C and D) how many ways can they be grouped as 2 objects when position does not matter (e.g. AB, AC, AD are correct but DA is not ok as is equal to AD.) An r-combination is simply a subset of the set with r elements. An r-combination is simply a subset of the set with r elements. C ( n, r ) = n! r! ( n-r )!

Base Conversion The base value of a number system is the number of different values the set has before repeating itself. For example, decimal has a base of ten values, 0 to 9. The base value of a number system is the number of different values the set has before repeating itself. For example, decimal has a base of ten values, 0 to 9.  Binary = 2 (0, 1)  Octal = 8 (0 - 7)  Decimal = 10 (0 - 9)  Duodecimal = 12 (used for some purposes by the Romans)  Hexadecimal = 16 (0 - 9, A-F)  Vigesimal = 20 (used by the Mayans)  Sexagesimal = 60 (used by the Babylonians)

Base Conversion Successive Division Successive Division  base 6  37/6 = 6 r 1  6/6 = 1 r 0  1/6 = 0 r 1   base 6 = 101

Base Conversion base base 10  1x6 0 +0x6 1 +1x6 2 = = base base base base13