BIT152 · 2081 · 10 marks
Define Boolean function, exponential function and partial ordering. List the computer representations for following set over universal set U = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9: (a) Set that contains even number (b) Set that contains multiple of 5 (c) Set that contains number greater than 7 (d) Set that
Define Boolean function, exponential function and partial ordering. List the computer representations for following set over universal set $U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}$: (a) Set that contains even number (b) Set that contains multiple of 5 (c) Set that contains number greater than 7 (d) Set that contains prime number. [6+4]
Boolean Function, Exponential Function, Partial Ordering & Computer Representation of Sets
Given
- Universal set: $U = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}$ (10 elements)
- Required definitions: Boolean function, exponential function, partial ordering.
- Sets to represent as bit strings over $U$:
- (a) even numbers
- (b) multiples of 5
- (c) numbers greater than 7
- (d) prime numbers
Solution
(a) Definitions
Boolean Function
A Boolean function of $n$ variables is a function
$$f: {0,1}^n \rightarrow {0,1}$$
that assigns to each combination of $n$ Boolean inputs (0 or 1) a single output value in ${0,1}$. It is built from the operations AND ($\cdot$), OR ($+$), and complement ($\overline{\phantom{x}}$).
Example: $f(x,y,z) = x\cdot y + \overline{z}$.
Exponential Function
An exponential function has the form
$$f(x) = a^x, \quad a > 0,\ a \neq 1$$
where $a$ is the base and $x$ the exponent. Domain $=\mathbb{R}$, range $=(0,\infty)$.
Example: $f(x)=2^x$; occurs in complexity analysis such as $O(2^n)$.
Partial Ordering
A relation $R$ on a set $S$ is a partial ordering if it is:
| Property | Condition |
|---|---|
| Reflexive | $\forall a \in S,\ (a,a)\in R$ |
| Antisymmetric | $(a,b)\in R \wedge (b,a)\in R \Rightarrow a=b$ |
| Transitive | $(a,b)\in R \wedge (b,c)\in R \Rightarrow (a,c)\in R$ |
The pair $(S,R)$ is a partially ordered set (poset).
Example: $\leq$ on $\mathbb{Z}$, and $\subseteq$ on a power set.
(b) Computer Representation of Sets
Convention: Order the elements of $U$ as $0,1,2,3,4,5,6,7,8,9$. Bit = 1 if the element is present, 0 otherwise.
$$\text{Positions: } 0\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9$$
(a) Even numbers
$A = {0,2,4,6,8}$
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
$$\boxed{1010101010}$$
(b) Multiples of 5
$B = {0,5}$
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
$$\boxed{1000010000}$$
(c) Numbers greater than 7
$C = {8,9}$
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 |
$$\boxed{0000000011}$$
(d) Prime numbers
$D = {2,3,5,7}$ (1 is not prime)
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 | 0 |
$$\boxed{0011010100}$$
Summary
| Set | Elements | Bit string |
|---|---|---|
| (a) Even | ${0,2,4,6,8}$ | $1010101010$ |
| (b) Mult. of 5 | ${0,5}$ | $1000010000$ |
| (c) $>7$ | ${8,9}$ | $0000000011$ |
| (d) Prime | ${2,3,5,7}$ | $0011010100$ |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.