Docsity

Master Theorem - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

Partial preview of the text

Download Master Theorem - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

CS 173:

Discrete Mathematical Structures

Divide and Conquer Recurrences

General form: T(n) = aT(n/b) + f(n)

What do the algorithms look like?

• Divide the problem into a

subproblems of size n/b.

• Solve those subproblems

(recursively).

• We understand how abstract this Conquer the solution in time f(n).

is. Some of us think cs125 should be a prerequisite for this course.

The only algorithms you have as examples are mergesort and binary search.

Relations

  • Recall the definition of the Cartesian (Cross) Product: The Cartesian Product of sets A and B, A x B, is the set A x B = {<x,y> : x∈A and y∈B}.
  • A relation is just any subset of the CP!!

R ⊆ AxB

  • Ex: A = students; B = courses. R = {(a,b) | student a is enrolled in class b}

Relations

  • Recall the definition of a function: f = {<a,b> : b = f(a) , a∈A and b∈B}
  • Is every function a relation?
  • Draw venn diagram of cross products, relations, functions

Yes, a function is a special kind of relation.

Properties of Relations

  • Transitivity:

A relation on AxA is transitive if (a,b) ∈ R and (b,c) ∈ R imply (a,c) ∈ R.

  • Anti-symmetry:

A relation on AxA is anti-symmetric if (a,b) ∈ R implies (b,a) ∉ R.

Properties of Relations - techniques…

How can we check for transitivity?

Draw a picture of the relation (called

a “graph”).

Vertex for every element of A

Now, what’s R? Edge for every element of R

A “short cut” must be present for EVERY path of length 2.

Properties of Relations - techniques…

How can we check for the symmetric

property?

Draw a picture of the relation (called

a “graph”).

Vertex for every element of A

Edge for every element of R

Now, what’s R?

EVERY edge must have a return edge.

Properties of Relations - techniques…

How can we check for the anti-

symmetric property?

Draw a picture of the relation (called a

“graph”).

Vertex for every element of A

Edge for every element of R

Now, what’s R?

No edge can have a return edge.

Properties of Relations - techniques…

Let R be a relation on positive

integers,

R={(x,y): 3|(x-y)}

Is R transitive? Yes

Suppose (x,y) and (y,z) are in R.

Then we can write 3j = (x-y) and 3k = (y-z) Definition of

“divides”

Can we say 3m = (x-z)? Is (x,z) in R?

Add prev eqn to get: 3j + 3k = (x-y) + (y-z)

3(j + k) = (x-z)

Properties of Relations - techniques…

Let R be a relation on positive

integers,

R={(x,y): 3|(x-y)}

Is R transitive? Yes

Is it reflexive? Yes

Is (x,x) in R, for all x?

Does 3k = (x-x) for some k?

Definition of “divides” Yes, for k=0.

Properties of Relations - techniques…

Let R be a relation on positive

integers,

R={(x,y): 3|(x-y)}

Is R transitive? Yes

Is it reflexive? Yes

Is it symmetric? Yes

Is it anti-symmetric? No

Suppose (x,y) is in R.

Then 3j = (x-y) for some j.

Definition of “divides”

Yes, for k=-j.

Does 3k = (y-x) for some k?

More than one relation

Suppose we have 2 relations, R 1 and

R 2 , and recall that relations are

just sets! So we can take unions,

intersections, complements,

symmetric differences, etc.

There are other things we can do aswell…

More than one relation

Let R be a relation on A. Inductively define

R 1 = R

R n+1^ = R n^ ° R

R 2 = R 1 °R = {(1,1),(1,2),(1,3),(2,3),(3,3),(4,1), (4,2)}

A A^ A

R R 1

More than one relation

Let R be a relation on A. Inductively define

R 1 = R

R n+1^ = R n^ ° R

R 3 = R 2 °R =

A A^ A

R R 2

4 … = R

= R

= R6…