May 8, 2002

1. State the following formula
** in English**, where the universe is ** the set of objects**
and the meaning of the predicate symbols are as follows:

: is a book.

: is difficult for .

: is expensive for .

: is a person.

(a)

Every book is difficult and expensive for everyone.

(b)

Every book is either difficult for someone or expensive for someone.

(c)

Everything is a book and expensive for someone.

2. Express the assertions given below as propositions of predicate logic using
the following predicates. The universe is ** the set of objects.**

: is a composite number.

: is divisible by .

: is a natural number.

: is a prime number.

a) Every natural number is prime.

b) 3 is prime.

c) For an integer to be composite, it is necessary that the integer is
divisible by some prime number.

3. Recursively define the set of powers of 2 including negative powers, that is, the set .

Let S denote the set of powers of 2.

Basis Clause: 1 is in S.

Inductive Clause: For any number x, if x is in S then x/2 and 2x are in S.

Extremal Clause: Nothing is in S unless it is obtained from the above two clauses.

4 (a) Express the argument given below as propositions of
** propositional logic**
using the symbol suggested for each proposition.

(b) Check whether or not the reasoning is correct.
Give your reasons.

If my program is not correct (),
then the seat must have been double booked that day().

Either the seat was not double booked
or the agent saw the double booking ().

If the flight was not overbooked on October 10 (), the agent did not see
the double booking.

Furthermore if the flight was overbooked on October 10, then the seat was
double booked and also no more seats were available ().

But we all know that there were some seats available.

Therefore my program is correct.

(a)

---------

(b) Since holds,
is false.

Hence from
by modus tollens .

Hence from

by modus ponens .

Hence from by disjunctive syllogism .

Hence from
by modus tollens .

5. Which of the following statements are true and which are false ?

(a) "For Mary to be happy it is necessary that John is with her" is logically
equivalent to "If Mary is happy, then John is with her". True

(b)
False

(c)
True

(d)
, where are sets. False

(e) The relation < (less than) over the set of natural numbers is
a partial order. False

(f) The relation Big-Oh on the set of functions is a total order. True

(g) If a relation is irreflexive and transitive, then it is antisymmetric.
True

(h) For a poset, if all the maximal elements are maximum and also if all the
minimal elements are minimum, then the order is a total order.
False

(i) If a function is one-to-one, then it has an inverse function. False

(j) The function over the set of nonnegative real numbers
is a bijection. True

6 (a) Prove that is an equivalence relation over the set of
functions.

(1) is reflexive. For since
.

(2) is symmetric. For
if and only if
and
, which also means
.

(3) is transitive. To prove this, let us first prove that big-oh is transitive.

if and only if there exist constants and such that
for all .

Also if and only if there exist constants and such that
for all .

Let be the larger of and .

Then
and
for all .

Hence
for all .

Hence
.
Thus big-oh is transitive.

If
and
, then
and
. Hence by the transitivity of big-oh,
.

Similarly since
and
,
.

Hence we can conclude that
.

Thus is transitive.

Since is reflexive, symmetric and transitive,
it is an equivalence relation.

(b) Give two elements of the equivalence class for the relation
.

Any quadratic functions will do. For example,
,
etc.

7. Prove by mathematical induction the following:

(a)

(b) The ** Bubble Sort** sorts keys
by comparing pairs of keys in adjacent locations and interchanging them if they are out of order. For example to sort the array of numbers 10, 8, 6, 4, 2
in increasing order, it first compares 10 and 8. Since 10 is larger,
it is interchanged with 8 to get 8, 10, 6, 4, 2. Next 10 is compared with 6.
Since 10 is larger, it is interchanged with 6 to get 8, 6, 10, 4, 2.
Two more iterations produces 8, 6, 4, 2, 10. That is the largest number
in the array has been brought to the rightmost location.

Then the process starts all over from the first location to bring the next largest number to the next rightmost (next to 10) location, that is,
6, 4, 2, 8, 10 is obtained.

Similarly 6 is percolated up next to get 4, 2, 6, 8, 10,
and finally 4 and 2 are interchanged to arrive at the sorted array
2, 4, 6, 8, 10.

In the above example the number of comparisons used is 4 + 3 + 2+ 1 = 10.
If there are six numbers in the array and they are ordered from the largest
to the smallest, then we need 5 + 4 + 3 + 2 + 1 = 15 comparisons to sort
them.

In general it seems to take (n-1) + (n-2) + ... + 2 + 1 = n(n-1)/2
comparisons to sort n numbers if they are arranged from largest to the smallest
in the array.

Now the question: Prove by mathematical induction that it does take n(n-1)/2
comparisons to sort numbers into increasing order that are stored in an array
in decreasing order.