Handout 4

Handout 4 - Mehran Sahami CS103B Handout#4 January 7 2009...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Mehran Sahami Handout #4 CS103B January 7, 2009 Introduction to Sets Portions of this handout was originally written by Maggie Johnson, however she cannot be held responsible for the humorless jokes now contained herein. Remembering those halcyon days of youth back in CS106B/X, you may recall encountering the Set abstract data type. Now, it's time to get a little more formal (please take a moment to change into black tie or evening gown attire…) with this concept, so that we can build on this concept mathematically (as opposed to programmatically). Sets are the most basic of mathematical structures. They are so basic, in fact, that they are hard to define without using the word "set" or some synonym of "set". The set concept allows us to talk about a collection of objects which has no repetition and ignores order (i.e., an unordered collection of unique objects). The only relationship between the elements of a set is that they all belong to the same set. We can speak of the set of integers (which is infinite), the set of real numbers (which is infinite in a different way), the set of good pizza places in Palo Alto (very finite), or the set of good pizza places in Libertyville, IL (empty set). Sorry if anyone reading this is from Libertyville. Definition : A set is a collection of distinct objects without repetition and without order. The objects in a set are called the elements or members of the set. We can formally define the members of a set in two ways. The first is simply to enumerate the members, as in: P = { Ramonas , Pizza-My-Heart }. Note that sets are traditionally given capital letters for names. Some important sets are given special names such as: R for the real numbers Q for the rational numbers Z for the integers N for the natural numbers The symbol denotes membership in a set, and denotes non-membership in a set. Thus, Ramonas P , but Jiffy-Lube P , meaning that Ramona’s is a good place to buy pizza, but Jiffy- Lube is not. A set with no members, known as the empty set , is denoted by empty braces {} or by the symbol . The second way to define a set is to specify some condition for membership. This is referred to as set builder notation . For example: Q = { p/q | p, q Z and q 0}. defines the set of rational numbers. The vertical bar | is read "such that." This definition works because there is an understanding that the set contains every number p/q that satisfies the condition to the right of the bar. As another example, the set of positive odd integers {1, 3, 5, 7, 9, 11, . .. } can be defined as: { n | n = 2k+1 for integer k >= 0 }
Background image of page 1

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

View Full Document Right Arrow Icon
- 2 - Fun Facts About Sets Here are some important facts about sets. Learn them, know them, love them, live them… 1) Two sets are equal if and only if they have the same elements. For example: {3, 5, 1} = {5, 1, 3} 2) If A and B are sets, then A is a subset of B (denoted A B) if and only if every element of A is also an element of B. Analogously, A is a superset of B (denoted A
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 11

Handout 4 - Mehran Sahami CS103B Handout#4 January 7 2009...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online