MCS680: Foundations Of Computer Science

Slides:



Advertisements
Similar presentations
Chapter 2 Revision of Mathematical Notations and Techniques
Advertisements

Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Instructor: Hayk Melikya
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
The Engineering Design of Systems: Models and Methods
Denoting the beginning
Discrete Structures Chapter 3 Set Theory Nurul Amelina Nasharuddin Multimedia Department.
Sets, Relation and Functions A set is a collection of objects (elements) or a container of objects. Defining sets –Empty set (Ø): no elements –Universal.
Sets 1.
Sets 1.
SETS A set B is a collection of objects such that for every object X in the universe the statement: “X is a member of B” Is a proposition.
Relations Chapter 9.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Logics for Data and Knowledge Representation Introduction to Algebra Chiara Ghidini, Luciano Serafini, Fausto Giunchiglia and Vincenzo Maltese.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
Set, Combinatorics, Probability & Number Theory Mathematical Structures for Computer Science Chapter 3 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Set,
Sets Defined A set is an object defined as a collection of other distinct objects, known as elements of the set The elements of a set can be anything:
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
CS201: Data Structures and Discrete Mathematics I
CompSci 102 Discrete Math for Computer Science
Relations and their Properties
Mathematical Preliminaries
Sets Goal: Introduce the basic terminology of set theory.
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Chapter 2 With Question/Answer Animations. Section 2.1.
Introduction to Set theory. Ways of Describing Sets.
Chapter 9. Chapter Summary Relations and Their Properties n-ary Relations and Their Applications (not currently included in overheads) Representing Relations.
1 RELATIONS Learning outcomes Students are able to: a. determine the properties of relations – reflexive, symmetric, transitive, and antisymmetric b. determine.
Discrete Mathematics Set.
RelationsCSCE 235, Spring Introduction A relation between elements of two sets is a subset of their Cartesian products (set of all ordered pairs.
Set Theory Concepts Set – A collection of “elements” (objects, members) denoted by upper case letters A, B, etc. elements are lower case brackets are used.
1 Equivalence relations Binary relations: –Let S1 and S2 be two sets, and R be a (binary relation) from S1 to S2 –Not every x in S1 and y in S2 have such.
Relations and Functions ORDERED PAIRS AND CARTESIAN PRODUCT An ordered pair consists of two elements, say a and b, in which one of them, say a is designated.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Set Operations Section 2.2.
Theory of Computing Topics Formal languages automata computability and related matters Purposes To know the foundations and principles of computer science.
Theory of Computing Topics Formal languages automata computability and related matters Purposes To know the foundations and principles of computer science.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Section 6.1 Set and Set Operations. Set: A set is a collection of objects/elements. Ex. A = {w, a, r, d} Sets are often named with capital letters. Order.
Sets, Permutations, and Combinations. Lecture 4-1: Sets Sets: Powerful tool in computer science to solve real world problems. A set is a collection of.
Relations and Their Properties
Citra Noviyasari, S.Si, MT
Chapter 5 Relations and Operations
Sets.
Dr. Ameria Eldosoky Discrete mathematics
Set Definition: A set is unordered collection of objects.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Set Operations CS 202, Spring 2008 Epp, chapter 5.
Discrete Mathematical The Set Theory
Formal Language & Automata Theory
CSE15 Discrete Mathematics 05/03/17
Equivalence Relations
Set, Combinatorics, Probability & Number Theory
MCS680: Foundations Of Computer Science
Chapter 1 Logic and Proofs Homework 2 Given the statement “A valid password is necessary for you to log on to the campus server.” Express the statement.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
CS100: Discrete structures
8.5 Equivalence Relations
CHAPTER 1 - Sets and Intervals
CHAPTER 1 - Sets and Intervals
Copyright © Cengage Learning. All rights reserved.
Sungho Kang Yonsei University
Mathematical Background 1
Discrete Mathematics CS 2610
9.5 Equivalence Relations
Lecture Sets 2.2 Set Operations.
REVISION Relation. REVISION Relation Introduction to Relations and Functions.
Agenda Lecture Content: Relations (Relasi)
Presentation transcript:

MCS680: Foundations Of Computer Science int MSTWeight(int graph[][], int size) { int i,j; int weight = 0; for(i=0; i<size; i++) for(j=0; j<size; j++) weight+= graph[i][j]; return weight; } 1 n O(1) O(n) Running Time = 2O(1) + O(n2) = O(n2) Algorithms and Analysis of Sets Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Introduction The set is one of the most fundamental data model in Mathematics and Computer Science Many problems can be reduced to a set representation Many efficient algorithms exist for processing sets Goals Review set definition and basic operations that can be performed on sets Examine and analyze some set algorithms Investigate how some “ordinary” Computer Science problems can be reduced to sets They can then be solved using standard set algorithms Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Sets and Set Membership When S is a set and x is a piece of quantifiable data We need to be able to determine Is x a member of set S Is x not a member of set S Generally all members of a set are related in some way Set Notation The expression x  S means that the element x is a member of set S If x1, x2, ... xn are all members of the set S then we refer to set S as: S = { x1, x2, ... xn } The empty set is denoted as  The empty set is a set with no members Thus for all x, x   is always false Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Definition of Sets by Abstraction Enumerating all of the elements in a given set is not the only way we may define sets The number of elements in the set may be large The elements in the set may be related by some common property Notation for abstraction: {x | x  S and P(x)} This means that all elements x are in the set S if they satisfy property P(x) Examples {x | x  S and x is odd} {A | A  T and A is a set} {x | x  N and x is prime} Common infinite sets N is the set of non-negative integers, Z is the set of all integers, R is the set of real numbers, C is the set of complex numbers Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Set Operations Union, Intersection and Difference Union: S  T A set containing the elements in S or T, or both Intersection: S  T A set containing the the elements that are in both S and T The intersection of two sets includes the elements common to both sets Difference: S - T A set containing those elements that are in S but not in T The set contains the distinct elements that are in S with respect to T Example: Let S = {1, 2, 3}, T = {3, 4, 5} Union: S  T = {1, 2, 3, 4, 5} Intersection: S  T = {3} Difference: S - T = {1, 2} Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Venn Diagrams Region 1 Region 2 Region 3 Region 4 S T Venn diagrams are useful for visualizing set operations Region 1 represents those elements that are in neither S or T Region 2 represents S - T Region 3 represents S T Region 4 represents T - S Regions 2, 3 and 4 combined represents S  T Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Algebraic Laws For Union, Intersection and Difference Build up complex expressions using Union, Intersection and Difference Example: R  (( S  T) - U) Need to be able to determine if two expressions are equivalent Important algebraic laws Let the symbol  represent equivalence Commutative Law of Union (S  T)  (T  S) Rationale: The element x is in S  T, if x is in X or if x is in T, or both. That is also the condition where x is in T  S. Associative Law of Union (S  (T  R))  ((S  T)  R) This can be shown by the same argument used to show the commutative law Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Algebraic Laws For Union, Intersection and Difference Commutative Law of Intersection (S  T)  (T  S) Rationale: The element x is in sets S  T and T  S under exactly the same circumstances. Associative Law of Intersection (S  (T  R))  ((S  T)  R) Rationale: The element x must be in all three sets - S, T, and R. However it does not matter if we examine (T  R) or (S  T) first. Distributive law of intersection over union ((T  R)  S)  ((S  T)  (R  S)) Rationale: The element x must be in S and also in at least one of T or R Distributive law of union over intersection ((T  R)  S)  ((S  T)  (R  S)) Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Algebraic Laws For Union, Intersection and Difference Associative Law of Union and Difference (S - (T  R) )  ((S - T) - R) Rationale: Both sides contain an element x when x is in S but in neither T nor R. Associative Law of Intersection ((S  T) - R )  ((S - R)  (T - R)) Rationale: An element x is in either set when it is not in R, but is in either S or T, or both. Empty Set Identity (S  )  S and (  S)  S Rationale: The element x can only be in S, because it can not be in  Idempotence: When an operator is applied to the same value, the result is the same Union: (S  S)  S Intersection: (S  S)  S Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

The Subset Relationship If S and T are sets, then we can say that S  T is every member of S that is also a member of T S is a subset of T T is a superset of S S is contained in T T contains S If S and T are sets, then we can say that S  T, if S  T and there is at least one element in S that is not in T S is a proper subset of T T is a proper superset of S S is a properly contained in T T properly contains S Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

The Power Set of a Set The power set of S, is the set of subsets of S Notation: Let P(S) represent the power set of S 2S is also used Size of a power set A power set, P(S) has 2n members Example: Let S = {1,2,3} P(S) is: {,{1},{2},{3},{1,2},{1,3},{2,3},{1,2,3}} |P(S)| = 8 = 23 Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Cartesian Product Let A and B be two sets The product of A and B, denoted A x B is defined as the set of pairs in which the first component is chosen from A and the second component from B A x B = {(a,b) | a  A and b  B} This product is known as the Cartesian Product Example: Let A = {1,2} and B = {a,b,c} Thus A x B = {(1,a), (1,b), (1,c), (2,a), (2,b), (2,c)} Size of the Cartesian Product |A x B| = |A| * |B| If A = {1,2} and B = {a,b,c} Then |A| = 2, |B| = 3 and |A x B| = 6 Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Binary Relations and Functions A binary relation R is a set of pairs that is a subset of the product of two sets If a relation R is a subset of A x B, then we say that R is from A to B Remember that A x B  B x A A is the domain of the relation B is the range of the relation Notation: Given a binary relation R on sets A and B where a  A and b  B, we can show this relation as aRb Functions Partial Function: Relation R has the property that for every a  A there is at most one element b B such that satisfies aRb Total Function: Relation R has the property that for every a  A there is at exactly one element b B such that satisfies aRb Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Special Properties of Binary Relations Transitivity Let R be a binary relation. R is transitive whenever aRb and bRc are true, and aRc is also true Reflexivity Let R be a binary relation that for every element a in the domain aRa is true Symmetric Let R be a binary relation. R is symmetric if whenever aRb, we also have bRa Asymmetric Let R be a binary relation. R is asymmetric if whenever aRb, we only have bRa when a=b a a b a never b a Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Special Properties of Binary Relations - Examples Transitivity Consider the relation ‘<‘ on Z, the set of integers. If a < b, and b < c, then it follows that a < c. Consider the relation ‘’ on Z, the set of integers. If a  b, and b  c, then we can not say that a  c. This relation is not transitive Reflexivity The relation ‘’ is reflexive on the set of integers. For all integers a, a  a. Symmetric The relation ‘’ is symmetric on the set of integers. For all integers if a  b, then b  a must be true Asymmetric The relation ‘’ is asymmetric on the set of integers. If a  b, and b  a, then a = b Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Partial and Total Orders Partial Order A partial order is a transitive and antisymmetric binary relation Total Order A total order is a transitive, reflexive and antisymmetric binary relation where every pair of elements in the domain are comparable If R is a total order and if a and b are any two elements in its domain, then either aRb, or bRa is true All total orders must be reflexive because we might allow a and b to be the same element. Example: Partial Orders and Total Orders The relations ‘<‘ and ‘>’ are partial orders but not total orders. They are transitive and asymmetric, but not reflexive (a < a is false). The relations ‘’ and ‘’ are total orders. They are transitive, asymmetric, and reflexive Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS

Closure of a Binary Relation Closures of binary relations Take a relation that does not have a desired property Transitivity Reflexive Symmetric Asymmetric Add as few pairs as possible to crate a relation that does have the desired property The resultant relation is called the closure (for the desired property) of the original relation Closures are usually used to infer or discover missing information from the relation Brian Mitchell (bmitchel@mcs.drexel.edu) - Drexel University MCS680-FCS