Chapter 3 Sets.

Slides:



Advertisements
Similar presentations
Months of the year December January November October February
Advertisements

Introduction to Set Theory
Chubaka Producciones Presenta :.
Sets DISCRETE STRUCTURE ABDUL BASIT TAHIR, KAMRAN ALI, FAIZAN ILLAHI, NOMAN AHMAD, ARSALAN MUBASHIR.
2012 JANUARY Sun Mon Tue Wed Thu Fri Sat
P Pathophysiology Calendar. SundayMondayTuesdayWednesdayThursdayFridaySaturday January 2012.
Chicas, este calendario si es pa' nosotras !!!!!.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
School Year Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
2007 Monthly Calendar You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation.
MONDAYTUESDAYWEDNESDAYTHURSDAYFRIDAYSAT/SUN Note: You can print this template to use as a wall calendar. You can also copy the slide for any month to add.
You can print this template to use it as a wall calendar, or you can copy the page for any month to add it to your own presentation. If you’d like to change.
WORD JUMBLE. Months of the year Word in jumbled form e r r f b u y a Word in jumbled form e r r f b u y a february Click for the answer Next Question.
DATE POWER 2 INCOME JANUARY 100member X 25.00P2, FEBRUARY 200member X 25.00P5, MARCH 400member X 25.00P10, APRIL 800member.
Chapter 2 Section 2.1 Sets and Set Operations. A set is a particular type of mathematical idea that is used to categorize or group different collections.
Chapter 2 Sets and Functions Section 2.1 Sets. A set is a particular type of mathematical idea that is used to categorize or group different collections.
2011 Calendar Important Dates/Events/Homework. SunSatFriThursWedTuesMon January
TEMPORAL VISUALIZATION OF DATA FROM THE FRENCH SENTINEL NETWORK.
July 2007 SundayMondayTuesdayWednesdayThursdayFridaySaturday
Numbers and Sets. A set is a collection of objects. So, any collection of things, such as numbers, can be called a set. To show that we have a set, we.
Data Design and Implementation
CHAPTER 3 SETS, BOOLEAN ALGEBRA & LOGIC CIRCUITS
IS 350 Arrays.
Copyright © 2016, 2013, and 2010, Pearson Education, Inc.
JavaScript: Functions.
Dictation practice 2nd Form Ms. Micaela-Ms. Verónica.
McDonald’s Kalender 2009.
McDonald’s Kalender 2009.
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
Set-Builder Notation.
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
McDonald’s Kalender 2009.
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Problem Gambling Clicks to Opgr.org
2300 (11PM) September 21 Blue line is meridian..
January MON TUE WED THU FRI SAT SUN
McDonald’s calendar 2007.
1 - January - Sun Mon The Wed Thu Fri Sat
Teacher name August phone: Enter text here.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Circle Chart Template Process Name.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
JANUARY 2018 SUNDAY MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY
The Transformation of A Small Company Into A Golden Legend
February 2007 Note: Source:.
| January Sunday Monday Tuesday Wednesday Thursday Friday
January MON TUE WED THU FRI SAT SUN
MONTHS OF THE YEAR January February April March June May July August
S M T W F S M T W F
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
McDonald’s calendar 2007.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
HEALTHY LIFE STYLE CALENDAR.
Sets CS3240, L. grewe.
E W ©
Habitat Changes and Fish Migration
January Monday Tuesday Wednesday Thursday Friday Saturday Sunday 30 31
2015 January February March April May June July August September
Habitat Changes and Fish Migration
Section 2.1 Set Concepts.
Presentation transcript:

Chapter 3 Sets

Set Definitions The abstract (logical) view of sets comes from discrete mathematics. A set a is an unordered collection of items called set members. An item is either in the set (is a member) or not in the set (is not a member). A set often is written by enclosing the group of items enclosed in braces. {Apple Pear Cherry} {Orange Cherry Pear Apple Banana}

Special Sets Empty set The set with no members. Written as { } or  Universal set The set containing all the values of a component type. The universal set of fruits would contain all possible fruits

Membership Operation Membership - Is an item a member of a set? Membership Test Answer Apple in the set { Apple Pear Cherry } True Kumquat in the set { Apple Banana Lemon } False

Union, Intersection, and Difference are three operations that form a new set from two existing sets. Union The union of two sets is a set consisting of those components that are in the first set or in the second set. The or used here is the inclusive or. Intersection The intersection of two sets is a set consisting of those components occurring in the first set and in the second set. Difference The difference between two sets is the set of components in the first set that are not in the second.

Examples Union, Intersection, and Difference 1st Set 2nd Set Union Intersection Difference {P Q R} {S} {P Q R S} {} {A B C D} {B D F} {A B C D F} {B D} {A C} {L N} {L M N O P} {X Y Z}

Subset A subset is a set contained within another set. A set X is a subset of Y if each element of X is an element of Y. If at least one element of Y is not in X, then X is called a proper subset of Y.

Subset Examples First Set Second Set First is subset of Second First is proper subset of Second {A E I O U} {A B C D E F} False {A B C D} {A B C} {X Y Z} True {W X Y Z}

Adding and Removing Members Set Element Addition of Element Removal of Element {A E I O U} B {A B E I O U} {A B C D} {A C D}

UML Diagram of Set

Bingo Numbers Column Number Range B 1 to 15 I 16 to 30 N 31 to 45 G

Specification of Bingo Numbers package Bingo_Numbers is - This package defines Bingo numbers and their associated letters - - The range of numbers on a Bingo Card type Bingo_Number is range 0..75; - - 0 can't be called, it is only for the Free Play square subtype Callable_Number is Bingo_Number range 1..75; - - Associations between Bingo numbers and letters subtype B_Range is Bingo_Number range 1..15; subtype I_Range is Bingo_Number range 16..30; subtype N_Range is Bingo_Number range 31..45; subtype G_Range is Bingo_Number range 46..60; subtype O_Range is Bingo_Number range 61..75; - - The 5 Bingo letters type Bingo_Letter is (B, I, N, G, O); end Bingo_Numbers;

Specification of a Set of Bingo Numbers (1) with Bingo_Numbers; use Bingo_Numbers; package Bingo_Number_Set is subtype Element_Type is Bingo_Numbers.Callable_Number; type Set_Type is private; Empty_Set : constant Set_Type; Universal_Set : constant Set_Type; --------------------------------------------------------------------------- function Is_Member (Set : in Set_Type; Element : in Element_Type) return Boolean; ---------------------------------------------------------------------------- function "+" (Left : in Set_Type; Right : in Set_Type) return Set_Type; - - Returns the union of the two sets function "+" (Left : in Set_Type; Right : in Element_Type) return Set_Type; - - Adds an element to a set

Specification of a Set of Bingo Numbers (2) function "+" (Left : in Element_Type; Right : in Set_Type) return Set_Type; - - Adds an element to a set function "*" (Left : in Set_Type; Right : in Set_Type) return Set_Type; -- Returns the intersection of the two sets function "-" (Left : in Set_Type; Right : in Set_Type) return Set_Type; - - Returns the difference of the two sets function "-" (Left : in Set_Type; Right : in Element_Type) return Set_Type; - - Removes an element from the set

Specification of a Set of Bingo Numbers (3) function "<=" (Left : in Set_Type; Right : in Set_Type) return Boolean; - - Returns True if Left is a subset of Right function "<" (Left : in Set_Type; Right : in Set_Type) return Boolean; - - Returns True if Left is a proper subset of Right function ">=" (Left : in Set_Type; Right : in Set_Type) return Boolean; - - Returns True if Right is a subset of Left function ">" (Left : in Set_Type; Right : in Set_Type) return Boolean; - - Returns True if Right is a proper subset of Left private - - We look at this part next end Bingo_Number_Set;

A Set of Bingo Numbers Stored as an Array of Booleans Each of the 75 Bingo Numbers is either in My_Set or not in My_Set

Examples of Set Operations

Private Part of Bingo Number Specification type Set_Type is array (Element_Type) of Boolean; - - Completion of deferred constants Empty_Set : constant Set_Type := (Element_Type => False); Universal_Set : constant Set_Type := (Element_Type => True); end Bingo_Number_Set;

Programming for Reuse Generic Units Generic Unit A template for a package or subprogram. Instance A package or subprogram created from a generic unit. Generic Formal Parameter A parameter defined in a generic unit declaration. Used to customize a generic unit for a specific problem. Instantiation A declaration that creates an instance of a generic unit.

A Generic Set Class and Three Instances

EBNF for Generic Units (1) generic_declaration ::= generic_subprogram_declaration | generic_package_declaration generic_subprogram_declaration ::= generic_formal_part subprogram_specification; generic_package_declaration ::= generic_formal_part package_specification; generic_formal_part ::= generic {generic_formal_parameter_declaration | use_clause} generic_formal_parameter_declaration ::= formal_object_declaration | formal_type_declaration | formal_subprogram_declaration | formal_package_declaration formal_type_declaration ::= type defining_identifier [discriminant_part] is formal_type_definition;

EBNF for Generic Units (2) formal_type_declaration ::= type defining_identifier [discriminant_part] is formal_type_definition; formal_type_definition ::= formal_discrete_type_definition | formal_signed_integer_type_definition | formal_modular_type_definition | formal_floating_point_definition | formal_ordinary_fixed_point_definition | formal_decimal_fixed_point_definition | formal_array_type_definition | formal_private_type_definition | formal_access_type_definition | formal_interface_type_definition

EBNF for Generic Units (3) formal_discrete_type_definition ::= (<>) formal_signed_integer_type_definition ::= range <> formal_modular_type_definition ::= mod <> formal_floating_point_definition ::= digits <> formal_ordinary_fixed_point_definition ::= delta <> formal_decimal_fixed_point_definition ::= delta <> digits <> formal_array_type_definition ::= array_type_definition formal_private_type_definition ::= [limited] private formal_subprogram_declaration ::= with subprogram_specification; formal_package_declaration ::= with package defining_identifier is new generic_package_name formal_package_actual_part;

Generic Selection Sort type Element_Type is private; type Array_Type is array (Positive range <>) of Element_Type; with function "<" (Left : in Element_Type; Right : in Element_Type) return Boolean; procedure Selection_Sort (The_Array : in out Array_Type); -- Purpose : Sort an array of elements into ascending order

Instantiation of Generic Selection Sort type Part_Rec is record Part_Number : Positive; Quantity : Natural; end record; -- The array type that we will sort type Part_Array is array (Positive range <>) of Part_Rec; -- A function to compare two inventory records function "<" (Left : in Part_Rec; Right : in Part_Rec) return Boolean is begin return Left.Part_Number < Right.Part_Number; end "<"; -- The inventory part sorting procedure procedure Part_Sort is new Selection_Sort (Element_Type => Part_Rec, Array_Type => Part_Array, "<" => "<");

Generic Binary Search generic type Index_Type is (<>); type Element_Type is limited private; type Array_Type is array (Index_Type range <>) of Element_Type; with function "<" (Left : in Element_Type; Right : in Element_Type) return Boolean; with function "=" (Left : in Element_Type; procedure Binary_Search (List : in Array_Type; Value : in Element_Type; Found : out Boolean; Location : out Index_Type); -- Purpose : Search List for Value -- Preconditions : List is in ascending order -- Postconditions : Value is in List and Found and List(Location) = Value -- or -- Value is not in List and not Found

Two Instantiations of Generic Binary Search type Month_Type is (January, February, March, April, May, June, July, August, September, October, November, December); type Nat_Array is array (Month_Type range <>) of Natural; type Int_Array is array (Positive range <>) of Integer; procedure Nat_Search is new Binary_Search (Element_Type => Natural, Index_Type => Month_Type, Array_Type => Nat_Array, "<" => "<", "=" => "="); procedure Int_Search is new Binary_Search (Element_Type => Integer, Index_Type => Positive, Array_Type => Int_Array, "<" => Standard."<", "=" => Standard."=");