chapter 2

13
Chapter 2 Chapter 2 Mathematical Preliminaries Mathematical Preliminaries

Upload: perrin

Post on 05-Jan-2016

16 views

Category:

Documents


0 download

DESCRIPTION

Chapter 2. Mathematical Preliminaries. Sets and Relations. A set is a collection of distinguishable members or elements The members are usually drawn from some larger base set Each member is either a primitive element of the base set or a set itself - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter 2

Chapter 2Chapter 2

Mathematical PreliminariesMathematical Preliminaries

Page 2: Chapter 2

Sets and RelationsSets and Relations

A A setset is a collection of distinguishable is a collection of distinguishable membersmembers or or elementselements

The members are usually drawn from some The members are usually drawn from some larger larger base setbase set

Each member is either a primitive element of Each member is either a primitive element of the base set or a set itselfthe base set or a set itself

The is no concept of duplication in a setThe is no concept of duplication in a set Each value from the base type is either in the Each value from the base type is either in the

set or notset or not Example 3, 4, 5 are in set P and the base type is Example 3, 4, 5 are in set P and the base type is

intsints

Page 3: Chapter 2

BagsBags

Sometimes we wish to define a collection Sometimes we wish to define a collection without order, like a set, but with without order, like a set, but with duplicate itemsduplicate items

Such a collection is called a Such a collection is called a bagbag To distinguish a bag from a set we put To distinguish a bag from a set we put

square brackets around a bag’s elementssquare brackets around a bag’s elements

Page 4: Chapter 2

SequencesSequences

A A sequencesequence is a collection of elements is a collection of elements with an order and which may contain with an order and which may contain duplicate-value elements.duplicate-value elements.

A sequence is also sometimes called a A sequence is also sometimes called a tuple tuple or a or a vectorvector

A sequence is indicated using angle A sequence is indicated using angle brackets <>brackets <>

Page 5: Chapter 2

RelationRelation

A A relationrelation R over set R over set SS is a set of ordered pairs is a set of ordered pairs from from SS

If tuple <x,y> is in If tuple <x,y> is in relation R, we can show relation R, we can show it as xRyit as xRy

We can define the We can define the following properties of following properties of relations:relations:

R is R is reflectivereflective if aRa for if aRa for all a in all a in SS

R is R is symmetricsymmetric if if whenever aRb, then bRa whenever aRb, then bRa for all a,b in for all a,b in SS

R is R is antisymmetricantisymmetric if if whenever aRb and bRa, whenever aRb and bRa, then a=b for all a,b in then a=b for all a,b in SS

R is R is transitivetransitive if if whenever aRb and bRc whenever aRb and bRc then aRc for all a,b,c in then aRc for all a,b,c in SS

Page 6: Chapter 2

Equivalence RelationEquivalence Relation

R is an R is an equivalence relationequivalence relation on set on set SS if if it is reflexive, symmetric and transitiveit is reflexive, symmetric and transitive

An equivalence relation can be used to An equivalence relation can be used to partition a set into partition a set into equivalence classesequivalence classes

An equivalence relation on set An equivalence relation on set SS partitions the sets into subsets whose partitions the sets into subsets whose elements are equivalentelements are equivalent

Page 7: Chapter 2

Partial OrderPartial Order

A binary relation is called a A binary relation is called a partial orderpartial order if it is antisymmetric and transitive.if it is antisymmetric and transitive.

The set on which the partial order is The set on which the partial order is defined is called a defined is called a partially ordered set partially ordered set or a or a posetposet

Page 8: Chapter 2

Miscellaneous NotationMiscellaneous Notation

B means bytesB means bytes b means bitsb means bits KB is a kilobyte 2KB is a kilobyte 21010 = 1024 byes = 1024 byes MB is a megabyte 2MB is a megabyte 22020 bytes bytes GB is a gigabyte 2GB is a gigabyte 23030 bytes bytes

Page 9: Chapter 2

n!n!

The The factorialfactorial function for integer n is the function for integer n is the product of the numbers between 1 and nproduct of the numbers between 1 and n

Stirling’s approximation is n! Stirling’s approximation is n! ≈ √2≈ √2ππn(n/n(n/ee))nn

Page 10: Chapter 2

RecursionRecursion

Recursion is awesome!!Recursion is awesome!! Two partsTwo parts

Base caseBase case Recursive callRecursive call

You’ll see a lot more of recursion this You’ll see a lot more of recursion this semestersemester

Page 11: Chapter 2

Proof StrategiesProof Strategies

Proof by contradictionProof by contradiction Proof by Mathematical InductionProof by Mathematical Induction

Base caseBase case Inductive HypothesisInductive Hypothesis

(seem familiar)(seem familiar)

Page 12: Chapter 2

EstimatingEstimating

Estimating can be formalized by a three Estimating can be formalized by a three step processstep process

1.1. Determine the major parameters that affect Determine the major parameters that affect the problemthe problem

2.2. Derive an equation that relates the Derive an equation that relates the parameters to the equationparameters to the equation

3.3. Select values for the parameters, and Select values for the parameters, and apply the equation to yield an estimated apply the equation to yield an estimated solutionsolution

Page 13: Chapter 2

ExampleExample

How many golf balls can fit in room that How many golf balls can fit in room that is 8” x 8” x 8”is 8” x 8” x 8” Parameters: a golf ball is 1’ diameterParameters: a golf ball is 1’ diameter The room is 4096 cubic feetThe room is 4096 cubic feet You can fit 1728 golf balls in 1 cubic footYou can fit 1728 golf balls in 1 cubic foot So you can fit 4096 * 1728 total golf ballsSo you can fit 4096 * 1728 total golf balls 7,077,888 golf balls7,077,888 golf balls The units do to match!!The units do to match!!