Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.

Slides:



Advertisements
Similar presentations
Union Definition: The union of sets A and B, denoted by A B, contains those elements that are in A or B or both: Example: { 1, 2, 3} {3, 4, 5} = { 1,
Advertisements

More Set Definitions and Proofs 1.6, 1.7. Ordered n-tuple The ordered n-tuple (a1,a2,…an) is the ordered collection that has a1 as its first element,
Greed is good. (Some of the time)
Discrete Mathematics Lecture 5 Alexander Bukharovich New York University.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Structures & Algorithms Basics of Set Theory EECE 320 — UBC.
Instructor: Hayk Melikya
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Week 21 Basic Set Theory A set is a collection of elements. Use capital letters, A, B, C to denotes sets and small letters a 1, a 2, … to denote the elements.
Denoting the beginning
CS5371 Theory of Computation Lecture 1: Mathematics Review I (Basic Terminology)
Sets 1.
Sets 1.
Sets. Copyright © Peter Cappello Definition Visualize a dictionary as a directed graph. Nodes represent words If word w is defined in terms of word.
1 Set Theory. 2 Set Properties Commutative Laws: Associative Laws: Distributive Laws:
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.
Mathematics.
Discrete Maths Objective to re-introduce basic set ideas, set operations, set identities , Semester 2, Set Basics 1.
Set theory Sets: Powerful tool in computer science to solve real world problems. A set is a collection of distinct objects called elements. Traditionally,
Sets Set Operations Functions. 1. Sets 1.1 Introduction and Notation 1.2 Cardinality 1.3 Power Set 1.4 Cartesian Products.
2.1 – Sets. Examples: Set-Builder Notation Using Set-Builder Notation to Make Domains Explicit Examples.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets.
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:
Connecting Discrete Structures to the “Real World” Using Market Basket Analysis (and Gray Codes) to Integrate and Motivate Topics in Discrete Structures.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Discrete Mathematics and Its Applications Sixth Edition By Kenneth Rosen Copyright  The McGraw-Hill Companies, Inc. Permission required for reproduction.
1.4 Sets Definition 1. A set is a group of objects . The objects in a set are called the elements, or members, of the set. Example 2 The set of positive.
Discrete Structure Sets. 2 Set Theory Set: Collection of objects (“elements”) a  A “a is an element of A” “a is a member of A” a  A “a is not an element.
CS201: Data Structures and Discrete Mathematics I
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
CompSci 102 Discrete Math for Computer Science
ELEMENTARY SET THEORY.
Chapter SETS DEFINITION OF SET METHODS FOR SPECIFYING SET SUBSETS VENN DIAGRAM SET IDENTITIES SET OPERATIONS.
Mathematical Preliminaries
Sets Goal: Introduce the basic terminology of set theory.
Fall 2008/2009 I. Arwa Linjawi & I. Asma’a Ashenkity 11 Basic Structure : Sets, Functions, Sequences, and Sums Sets Operations.
Chapter 2 With Question/Answer Animations. Section 2.1.
Introduction to Set theory. Ways of Describing Sets.
Discrete Mathematics SETS. What is a set? ^A set is a unordered collection of “objects”  People in a class: {A yşe, B arış, C anan }  Cities in Turkey.
Discrete Mathematics. Set Theory - Definitions and notation A set is an unordered collection of elements. Some examples: {1, 2, 3} is the set containing.
Discrete Mathematics CS 2610 January 27, part 2.
Discrete Mathematics Set.
1 Section 1.2 Sets A set is a collection of things. If S is a set and x is a member or element of S we write x  S. Othewise we write x  S. The set with.
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.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Fr: Discrete Mathematics by Washburn, Marlowe, and Ryan.
Discrete Mathematics CS 2610 August 31, Agenda Set Theory Set Builder Notation Universal Set Power Set and Cardinality Set Operations Set Identities.
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.
Thinking Mathematically Venn Diagrams and Set Operations.
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.
Introduction to Set Theory (§1.6) A set is a new type of structure, representing an unordered collection (group, plurality) of zero or more distinct (different)
CPCS 222 Discrete Structures I
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.
Sets.
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
Discrete Mathematical The Set Theory
CSNB 143 Discrete Mathematical Structures
Set, Combinatorics, Probability & Number Theory
Sets Section 2.1.
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from “Discrete.
Exercises Show that (P  Q)  (P)  (Q)
CS100: Discrete structures
Discrete Mathematics CS 2610
Discrete Mathematics R. Johnsonbaugh
Lecture Sets 2.2 Set Operations.
Presentation transcript:

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Sets

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction –Sets are an important mathematical data structure Naturally occurring Theoretically described Powerful notation –Definition An unordered collection of distinct objects that share one or more common property –Unordered means no inherent order –Distinct means there are no duplicate member  x[(x  S  P(x))  (P(x)  x  S)] Element of

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Notation and Terms (1) –Sets are denoted with capital letters –Curley brackets are also used {a,b,c} –Empty Set denoted by  or {} not the same as {  } –Finite sets can be defined by enumerating the elements of the set –Infinite sets require definition of defining property { x | P(x) } Example: { x | x  n  x  10 } Such that set of all nonnegative integers

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Notation and Terms (2) –Other Commonly Used Sets Z : set of all integers Q : set of all rational numbers R : set of all real numbers C : set of all complex numbers Z + : set of all positive integers –Subset (A  B)  x (x  A  x  B) A  B proper subset –  x (x  A  x  B)   x(x  B  x  A) –Equal Sets (A = B)  x [(x  A  x  B)  (x  B  x  A)] (A  B)  (B  A)

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Notation and Terms (3) –Power Set (  (S) ) |  (S)| = 2 n where n = |S| Note: the empty set is a subset of every set –Venn Diagrams

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Set Operations (1) –Union (A  B) {x | x  A  x  B} –Intersection (A  B) {x | x  A  x  B} –Complement (A) For a set A   (S), A is {x | x  S  x  A} –Set Difference (A – B) { x | x  A  x  B } –Cartesian Product (A  B) {(x,y) | x  A  y  B} Ordered pair

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Set Identities IdentityName A   = A A  U = A Identity Laws A  U = U A   =  Domination Laws A  A = A A  A = A Idempotent Laws (A) = A Complementation Laws A  B = B  A A  B = B  A Commutative Laws A  (B  C) = (A  B)  C A  (B  C) = (A  B)  C Associative Laws A  (B  C) = (A  B)  (A  C) A  (B  C) = (A  B)  (A  C) Distributive Laws (A  B) = A  B (A  B) = A  B De Morgan’s Laws A  (A  B) = A A  (A  B) = A Absorption Laws A  A = U A  A =  Complement Laws

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Minimal Spanning Trees (1) A tree is nothing more than an undirected graph without cycles A spanning tree is a tree that contains all the vertices in the graph There can be many such spanning trees and we usually want to find the optimal (minimal) weighted one –Thus, this is an optimization problem

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Minimal Spanning Trees (2) MST AB CD E AB CD E AB CD E

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Minimal Spanning Trees (3) PRIM’s Algorithm Given a set of vertices, V, and a set of edges, E Start with an empty set of edges, F, and a set of vertices, Y, initialized to contain an arbitrary vertex, say ‘a’ At each step find the minimum weight edge, where one end is from (V-Y) and the other from Y –Add this edge to F –Add the vertex from the edge not in Y to the set Y The problem is solved when Y = V

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Minimal Spanning Trees (4) AB CD E AB CD E AB CD E AB CD E AB CD E

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. KRUSKAL’s Algorithm Given a set of vertices, V, and a set of edges, E Start by creating disjoint subsets of V, one for each vertex, containing only that vertex Look at each edge in turn, from minimal weight to maximum weight If the edge connects two vertices in disjoint subsets then the edge is added to the MST and the two disjoint subsets are merged Otherwise we throw away the edge and leave the subsets alone Stop when we only have 1 disjoint subset or we run out of edges to consider Application: Minimal Spanning Trees (5)

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Minimal Spanning Trees (6) AB CD E AB CD E AB CD E AB CD E AB CD E AB CD E AB CD E

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Market Basket Analysis (1) –Who cares? –Sets are a natural and powerful way to describe the algorithmic solution to many problems –Market Basket Analysis: the use of association techniques to find groups of items that tend to occur together in transactions frequent item sets –sets of items that occur above some minimum threshold (called the minimum support) –example: {a,b,c,d} occurs 12 times (min. support == 10) association rules –a,b,c  d iff support({a,b,c,d}) / support({a,b,c})  r (called minimum confidence) –a,b  c,d iff support({a,b}) / support({c,d})  r –how many such rules are there? –Suggestive Sell When the client selects the antecedent items suggest that they select the consequent items

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Market Basket Analysis (2) –Apriori Algorithm (Agrawal et al., 1993) Let I = {a,b,c,…} be a set of all items in the domain Let T = { S | S  I } be a bag of all transaction records of item sets Let support(S) =  {A | A  T  S  A} | Let L 1 = { {a} | a  I  support({a})  minSupport }  k (k > 1  L k-1   ) Let L k = { S i  S j | (S i  L k-1 )  (S j  L k-1 )  ( |S i – S j | = 1 )  ( |S j – S i | = 1)  (  S[ ((S  S i  S j )  (|S| = k-1))  S  L k-1 ] )  ( support(S i  S j )  minSupport ) Then, the set of all frequent item sets is given by L = L k and the set of all association rules is given by R = { A  C | A   (L k )  (C = L k – A)  (A   )  (C   ) support(L k ) / support(A)  minConfidence } Filter

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Market Basket Analysis (3) –Example: minSupport = 2 I= {Table Saw, Router, Kreg Jig, Sander, Drill Press} T= {{Table Saw, Router, Drill Press}, { Router, Sander }, { Router, Kreg Jig }, {Table Saw, Router,, Sander }, {Table Saw,, Kreg Jig }, { Router, Kreg Jig }, {Table Saw,, Kreg Jig }, {Table Saw, Router, Kreg Jig,, Drill Press}, {Table Saw, Router, Kreg Jig }} L 1 = { {T}, {R}, {K}, {S}, {D} } L 2 = { {R,T}, {K,T}, {D,T}, {K,R}, {R,S}, {D,R} } L 3 = { {K,R,T}, {D,R,T} } L 4 =  Rules = ???? Each item set has unique “id”

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Application: Set Representation –How can we effectively represent sets in a computer? –Solution I : Store as a collection of distinct items Inefficient since set operations will then require massive amounts of searching –Solution II: Store in some arbitrary but well defined order Let U be the universal set (assume finite & reasonable size) Order U, for instance, a 1, a 2, …, a 3 Represent A  U as a bit string of length n where the ith bit in the string is 1 if a i  A and 0 if a i  A. Intersection reduces to  Union reduces to  Compliment reduces to  Inefficient in terms of subset repetition –Solution III: Left to CS 265