Exercise 4
Let A be the set of integers between 100 and 999 inclusive.- (a) Express A in the form A = {x ∈ ?? : condition}
- (b) What is the cardinality of A?
Answer
Solution
- (a) A = {x ∈ Int : 100 ≤ x and x ≤ 999}. (There are other correct solutions.)
- (b) There are 999 integers between 1 and 999 inclusive. The set A does not contain the integers between 1 and 99 inclusive, and there are 99 of these. So A has cardinality 999 − 99 = 900.
Exercise 5
If B = {s ∈ SeqOfChar : s starts with ‘T’ and s has length 4}, which of the following is a member of the set B?Answer
Solution
- (a) “This” is in B. It is a string (a sequence of characters), it contains four characters (so has length 4), and it starts with the character ‘T’.
- (b) [‘T’, ‘h’, ‘i’, ‘s’, ‘.’] is not in B. It is a string starting with ‘T’, but it contains five characters (has length 5). (Do not forget to count the character ‘.’.)
- (c) [“T”, “h”, “i”, “s”] is not in B. Each member of this sequence is a string, not a character. (Note that “T”, etc, are enclosed in double inverted commas.)
No comments:
Post a Comment