1 / 18

Discrete Structures

Discrete Structures. Li Tak Sing( 李德成 ) mt263f-10.ppt. Hash examples.

Download Presentation

Discrete Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Discrete Structures Li Tak Sing(李德成) mt263f-10.ppt

  2. Hash examples • Let S={one,two,three, four, five, six, seven, eight, nine} and let f:SN9 be defined by f(x)=(3|x|) mod 9, where |x| means the number of letters in x. For each of the following gaps, construct a hash table that contains the strings of S by choosing a string for entry in the table by the order that it is listed in S. Resolve collisions by linear probing with the given gap and observe whether all strings can be placed in the table. • Gap=1 • Gap=2 • Gap=3

  3. Countability • Let A and B be sets. If there is a bijection between A and B, we'll denote the fact by writing |A|=|B|. • In this case, we'll say that A and B have the same size or have the same cardinality.

  4. Finite sets examples • Find the cardinality of each set by establishing a bijection between it and a set of the form {0,1,...,n}. • {2x+5|xN and 12x+5100}. • {x2|x N and 0x2 500} • {2,5,8,11,...,44,47}

  5. Cardinality of an infinite set • Let Odd denote the set of odd natural numbers. Then the function f:NOdd defined by f(x)=2x+1 is a bijection. Therefore |N|=|Odd|. • If there is an injection from A to B, we then |A||B|. • If there is an surjection from B to A, we have |A||B|. • If there is an injection from A to B, but no bijection between them, then|A|<|B|.

  6. Sets that are countable • A set is countable if it is finite or if there is a bijection between it and N. In the latter case, the set is said to be countably infinite. • S is countable if |S|=n where n is a natural number or |S|=|N|

  7. Countable Properties • Every subset of N is countable. • S is countable iff |S|<|N|. • Any subset of a countable set is countable. • Any image of a countable set is countable.

  8. Proof of rule 1 • If the subset is finite, then it is countable. If it is not finite, we can arrange the elements in ascending order and denote the elements as xo, x1, ...... So there is a bijection between {xo, x1,...} and N.

  9. Proof of rule 2 • If SN is countable, then either |S|=n or |S|=|N|. So |S||N|. • If |S||N|, then, there is an injection f from S to N. Now, |S|=|f(S)|. Now, f(S) is a subset of N, by rule 1, f(S) is countable. Therefore f(S) is either finite or |f(S)|=|N|. This imply either S is finite or |S|=|N|. Both imply that S is countable.

  10. Proof of rule 3 • If A is a countable set, then there is an injection from A to N. Assume that f:AN be one of the injective functions. Now, for any subject B of A, we define the function g: B N such that g(x)=f(x). It is obvious that g is also an injection. Therefore B is also countable.

  11. Proof of rule 4 • If A is a countable set, then there is an injection from A to N. Let f:A N be an injection. Now, for a function g: A B for every yg(A), there is an x A such that g(x)=y. Now, we define a function h: g(A) A such that h(y)=x so that g(x)=y and f(x) is maximum. Now, h must be an injection because an element in A cannot map with two different elements in B under g. Therefore, fh is an injection as both f and h are injections. fh is a function from g(A) to N. So g(A) is countable.

  12. NxN is countable • (0,0) has 1 element • (0,1), (1,0) have 2 elements • (0,2),(1,1),(2,0) have 3 elements • ..... • (0,n), (1,n-1),.....(0,n) have n+1 elements

  13. (0,0) maps to 0, • (0,1), (1,0) map to 1,1+1 • (0,2),(1,1),(2,0) map to (1+2),(1+2)+1,(1+2)+2 • ..... • (0,n), (1,n-1),.....(0,n) maps to (1+2+..n), (1+2+..n)+1,.....(1+2+...n)+n

  14. (0,0) maps to 0, • (0,1), (1,0) map to 1,2 • (0,2),(1,1),(2,0) map to 3,4,5 • ..... • (0,n), (1,n-1),.....(0,n) maps to (n2+n)/2, (n2+n)/2,....., (n2+n)/2+n

  15. Counting unions of countable sets • If So, S1,....Sn,.... is a sequence of countable sets, then the union SoS1 ....  Sn .... is a countable set.

  16. Proof • List the elements of Sn as xn0, xn1,..... • If Sn is finite, then repeat one of the elements indefinitely so that we have an infinite sequence of elements. • If So, S1,....Sn,.... is a finite sequence, then we repeat one of the set indefinitely so that we have an infinite sequence of sets. • (m,n) of NN is associated with xmn • The mapping is not bijective because some elements of NN is mapped to the same xmn. • However, the mapping is surjective because every element of xmn is associated with (m,n). So we have |N|=|NN|| SoS1 ....  Sn .... | and therefore SoS1 ....  Sn .... is countable.

  17. Countability of the rationals • Q+ ={m/n | m,nN and m,n0 } • We can associate each m/n with (m,n)NN. Therefore, |Q+||NN|=|N|. Therefore Q+ is countable. • Similary Q- ={-m/n | m,nN and m,n0 } and is also countable. • Therefore Q= Q+{0}  Q- should be countable.

  18. Examples • Show that each of the following sets is countable by establishing a bijection between the set and N. • The set of even natural numbers. • The set of negative integers. • The set of strings over {a} • The set of strings over {a} that have even length. • The set Z of integers. • The set of odd integers. • The set of even integers.

More Related