Anda di halaman 1dari 6

Midterm (Show/Explain all Work)

IST 230

Chapter 1
1.

Complete the following truth table for

( p ( r )) q .

(4 points)

p ( r )

( p ( r )) q

T
T
T
T
F
F
F
F

T
T
F
F
T
T
F
F

T
F
T
F
T
F
T
F

F
T
F
T
F
T
F
T

F
T
F
T
F
F
F
F

T
T
T
F
T
T
T
T

Chapter 2
2. In this question, the domain of discourse is the set of people in our IST 230 class. Define the following
predicates:
T(x): x is more than six feet tall.
S(x): x is less than five feet tall.
Translate the following English statements into a logical expression with the same meaning.
a. The negation of Everyone in our IST 230 class is more than six feet tall. Translate in two ways: one
using a universal quantifier and one using an existential quantifier. (4 points)

(xT(x))
x(T(x))
b. No one in our class is less than five feet tall. (2 points)

(xS(x))
3.

Let A and B be defined as follows:


A = {Tom, Bo}
B = {Java, Python, R}
a. Write the cross product AxB as a set of ordered pairs. (4 points)

Midterm (Show/Explain all Work)

IST 230

AxB = { (Tom, Java), (Tom, Python), (Tom, R), (Bo, Java), (Bo, Python), (Bo, R) }.

b. Write the cross product BxA as a set of ordered pairs. (4 points)


BxA = { (Java, Tom), (Java, Bo), (Python, Tom), (Python, Bo), (R, Tom), (R, Bo) }.

c. Write one ordered pair that is in the set AxB but is not in the set BxA. (2 points)
The ordered pair (Tom, Java) is in the set AxB, but it is not in the set BxA.

Chapter 3
4.

Let sets A and B be defined as follows:


A = {Java, Python, R}
B = {Tom, Bo}

a. List as a set of ordered pairs one 1-1 function from A to B, or explain why no such function exists.
(5 points)
There is no 1-1 function from A to B, because any function from A to B must hit some element
of B at least twice (since there are three elements in A and only two in B); hence, no such
function can be 1-1.

b.

List as a set of ordered pairs an onto function from A to B, or explain why no such function exists.
(5 points)

{ (Java, Tom), (Python, Bo), (R, Tom)}


c.

Let f:B -> A be given by this set of ordered pairs:


f = { (Tom, Java), (Bo, Python) }
If f has an inverse function, call it g and list g as a set of ordered pairs. If f has no inverse function,
explain why not. (5 points)
The function f:BA has no inverse function, because it is not onto, and in order for a function to
have an inverse, it needs to be 1-1 and onto.

Midterm (Show/Explain all Work)


5.

IST 230

Let A = {a1, a2} and B = {b1, b2, b3}. Let the function f:AB be given by the following set of ordered pairs:
f = {(a1,b2),(a2,b3)}. (10 points)
List as a set of ordered pairs a function g with the property that for all a in A g(f(a)) = a, and show that this
property holds. HINT: First identify the domain and the target of the function g. Second, think of g as
undoing what f does.
A function g:BA that satisfies the property is given by
g = { (b1,a1), (b2,a1), (b3,a2) }.
The property holds for a1 in A, because g(f(a1)) = g(b2) = a1. The property holds for a2 in A, because
g(f(a2)) = g(b3) = a2; and since a1 and a2 are the only elements of A, the property holds for all a in A.

Chapter 4
6. Given the following circuit, complete the output column on the table below. (10 points)

x
1
1
1
1
0
0
0
0

Inputs
y
1
1
0
0
1
1
0
0

z
1
0
1
0
1
0
1
0

Output
D
0
0
0
0
0
1
0
0

IST 230

Midterm (Show/Explain all Work)

Chapter 5
7. Draw the arrow diagram and the matrix representation for the following relation on the set {1, 2, 3, 4} (15
points)
R = { (1, 1), (1,4), (2,2), (3,4), (3, 2), (2, 1), (1, 3), (4,2)}.
a.

Draw the arrow diagram for R (a scan of a hand-drawn image is OK). (5 points)

b.

.
.

.
.

Draw the matrix representation for R. (5 points)

[ ]
1 0 11
1 10 0
0101
0100

c.

Explain why the relation R is or is not reflexive. (5 points)


You answer must begin with either The relation R is reflexive, because or The relation R is not
reflexive, because.

The relation R is not reflexive because it is not the case that for all elements x in {1,2,3,4} we have xRx.
Specifically, it is not the case that 3R3.

Midterm (Show/Explain all Work)

8.

IST 230

Define the following two relations on the set {a, b, c, d} (5 points)

S = { (a, b), (a, c), (c, d), (c, a) }


R = { (b, c), (c, b), (a, d), (d, b) }

Write S R as a set of one or more ordered pairs.


S o R = {(b, d), (b, a)}

Chapter 6
9.

Write an algorithm in pseudo-code with the following input and output (5 points).
Input: a1, a2,..., an, a sequence of integers.
Output: The smallest integer in the sequence.
smallest:=a1
For i=2 to n
If (ai < smallest)
{smallest:= ai }
End for
Return smallest

10. What is the value of count after the last iteration of the outer for loop? Be sure show your work. (10
points)
count :=0
For i= 1 to 2
For j=1 to 2
count :=j(count + 2i)
End-for
End-for
Start: count = 0
i = 1, j = 1
count = 1(0+2*1)=2
i = 1, j = 2
count = 2(2+ 2*1)=8
i = 2, j = 1
count = 1(8+ 2*2)=12
i = 2, j = 2
count = 2(12+ 2*2)=32

Here, the right-hand side is j times the quantity (count + 2i)

IST 230

Midterm (Show/Explain all Work)


Chapter 7
11. Find the next three terms (terms

a 4 ) of the recursively defined sequence


ak =ak 1+3 k , for all integers k 2 , where a1=1 . (10 points)
a2=a1 +3 2=1+6=7

a3=a2 +3 3=7 +9=16


a 4=a3 +3 4=16+12=28

a2

a3

Anda mungkin juga menyukai