Lecture 14 - Sets of Sets

# Lecture 14 - Sets of Sets - Sets of Sets(Computer Science...

This preview shows pages 1–2. Sign up to view the full content.

Sets of Sets (Computer Science Notes) Sets Containing Sets So far, most of our sets have contained atomic elements (such as numbers or strings) or tuples (e.g. pairs of numbers). Sets can also contain other sets. For example, {Z,Q} is a set containing two infinite sets. {{a, b}, {c}} is a set containing two finite sets. Sets containing sets arise naturally when an application needs to consider some or all of the subsets of a base set A. For example, suppose that we have a set of 6 students: A = {Ian,Chen,Michelle, Emily, Jose,Anne} We might divide A up into non-overlapping groups based on what dorm they live in: B = {{Ian,Chen, Jose}, {Anne}, {Michelle, Emily}} When a set like B is the domain of a function, the function maps an entire subset to an output value. For example, suppose we have a function f : B → {dorms}. Then f would map each set of students to a dorm. E.g. f({Michelle, Emily}) = Babcock. When manipulating sets of sets, it’s easy to get confused and “lose” a layer of structure. To avoid this, imagine each set as a box. Then F = {{a, b}, {c}, {a, p, q}} is a box containing three boxes. One of the inside boxes contains a and b, the other contains c, and the third contains a, p, and q. So the cardinality of B is three The empty set, like any other set, can be put into another set. So { } is a set containing the empty set. Think of it as a box containing an empty box. The set { , {3, 4}} has two elements: the empty set and the set {3, 4}. Power Sets and Set-Valued Functions If A is a set, the powerset of A (written P(A) is the set containing all subsets of A. For example, suppose that A = {1, 2, 3}. Then P(A) = { , {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}} Suppose A is finite and contains n elements. When forming a subset, we have two choices for each element x: include x in the subset or don’t include it. The choice for each element is independent of the choice we make for the other elements. So we have 2^n ways to form a subset and, thus, the powerset P(A) contains 2^n elements Notice that the powerset of A always contains the empty set, regardless of what’s in A. As a consequence, P( ) = { }. Powersets often appear as the co-domain of functions which need to return a set of values rather than just a single value. For example, suppose that we have the following graph whose set of vertices is V = {a, b, c, d, e, f, g, h} Now, let’s define the function N so that it takes a vertex as input and returns the neighbors of that vertex. A node might have one neighbor, but it could have several, and it might have no neighbors. So the outputs of N can’t be individual nodes. They must be

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/16/2011 for the course CS 173 taught by Professor Erickson during the Spring '08 term at University of Illinois, Urbana Champaign.

### Page1 / 4

Lecture 14 - Sets of Sets - Sets of Sets(Computer Science...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online