Vous êtes sur la page 1sur 6

Vinod H

Bachelor of Computer Application


Semester - 5
BC0052 Theory of Computer Science
Fall 2012 Assignment Set 1

Roll No: 521110833

Center Code: 03011


2
BC0052 Theory of Computer Science Set -1

1. Show that the relation a b(mod m) is an equivalence relation

Let a Z.

Reflexive: Since n divides a - a = 0, we have a a mod m.


Symmetric: Let a b mod m.
=> m divides a - b
=> m divides - (a - b)
=> m divides b - a
=> b a mod m.
Transitivity: Let a, b, c Z such that a b mod n, b c mod m.
=> m divides a - b, and m divides b - c
=> m divides ( a - b ) + ( b - c)
=> m divides a - c
=> a c mod m.
Hence the relation is an equivalence relation.

Example
Suppose m = 5. Then
*0+ = ,x / x 0 mod 5- = ,x / 5 divides x 0 = x- = ,, -10, -5, 0, 5, 10, -
[1] = ,x / x 1 mod 5- = ,x / 5 divides x - 1-= ,, -9, -4, 1, 6, -
*2+ = ,x / x 2 mod 5- = ,x / 5 divides x -2- = ,, -8, -3, 2, 7, 12, -
*3+ = ,x / x 3 mod 5- = , x / 5 divides x -3- = ,, -7, -2, 3, 8, 13, -
*4+ = ,x / x 4 mod 5- = , x / 5 divides x - 4- = ,, -6, -1, 4, 9, 14, -
Also it is clear that *0+ = *5+ = *10+ =
*1+ = *6+ = *11+ =
*2+ = *7+ = *12+ =
*3+ = *8+ = *13+ =
*4+ = *9+ = *14+ =

Therefore the set of equivalence classes is given by {[0], [1], [2], [3], [4]}.

2. Using the definition of order show that x2 + 2x + 1 is O(x2)


The functions f and g referred to in the definition of O-notation are defined as follows. For real numbers
x, f(x) = x2 + 2x + 1 and g(x) = x2
3
BC0052 Theory of Computer Science Set -1

For all real numbers x > 1, | x2 + 2x +1 | = x2 + 2x + 1


x2 + 2x2 + x2
4x2
4 | x2 |
Therefore, |f(x) | 4 | g(x) | for all x > 1 or | f(x) | C | g(x) | for all x > k
Where C = 4 and k = 1
Hence x2 + 2x +1 is O(x2)
Example
Use the definition of order to show that 5x3 3x + 4 is O(x3).

Solution: The functions f and g referred to in the definition of O-notation are defined as follows.

3. Prove by the method of contradiction that 2 is not a rational number


A rational number is of the form p/q where, q 0 and p, q are not having any common factors.
Assume that 2 is a rational number. So it can be written as

If p is even, then it can be written as p = 2k. Therefore 4k2 = 2q2. Therefore q is even.
This is a contradiction to our assumption that p and q have no common factors. Therefore 2 is not a
rational number.
Example
Give a proof by contradiction of if 3n + 2 is odd, then n is odd.
4
BC0052 Theory of Computer Science Set -1

Solution: Let p: 3n+2 is odd


q: n is odd.
To construct a proof by contradiction, assume that both p and ~ q are true. That is, assume that 3n + 2 is
odd and that n is not odd.
Since n is not odd, it is even.
Now we can show that if n is even, then 3n + 2 is even.
(Verification: n is even n = 2k for some integer k. Substituting 2k for n,
we get 3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1) 3n + 2 is even).
Now the statement 3n + 2 is even is ~ p. Now since p and ~ p are true, we have a contradiction.
This completes the proof by contradiction, proving that if 3n + 2 is odd, then n is odd.

4. Prove by mathematical induction 12+ 22 + 32 + . + n2 = n (n + 1)(2n + 1)


6
(i) Base Step: Let n = 0. Then the sum on the left is zero, since there is nothing to add. The
expression on the right is also zero.
If n=1, left side. = 12=1.

Right Side =
Hence the result is true for n=1
(ii) Induction Hypothesis: Assume that the result to be true for n=m

Then 12 + 22 + + m2 = 12 + 22 + 32 + + m2 + (m + 1)2 =
Adding the (m + 1)th term i.e. (m + 1)2 to both side of the above equation, we get

Therefore the result is true for n = m+1. Hence by mathematical induction the given result is true for all
positive integers n.
5
BC0052 Theory of Computer Science Set -1

5. Prove that The sum of the degrees of the vertices of a graph G is twice the number of
edges

The sum of the degrees of the vertices of a graph G is twice the number of edges. That is, =

2e. (Here e is the number of edges).

Proof: (The proof is by induction on the number of edges e).

Case-(i): Suppose e = 1. Suppose f is the edge in G with f = uv.

Then d(v) = 1, d(u) = 1. Therefore

= + d (u) + d (v) = 0 + 1 + 1 = 2 = 2 1

= 2 (number of edges).

Hence the given statement is true for n = 1.

Now we can assume that the result is true for e = k - 1.

Take a graph G with k edges.

Now consider an edge f in G whose end points are u and v.

Remove f from G.

Then we get a new graph G* = G - {f}.

Suppose d*(v) denotes the degree of vertices v in G*.

Now for any x {u, v}, we have d(x) = d*(x), and

d*(v) = d(v) -1, d*(u) = d(u) - 1.

Now G* has k - 1 edges. So by induction hypothesis

= 2(k - 1).

Now 2(k - 1) = = + d*(u) + d*(v)

= + (d(u) - 1) + (d(v) - 1)

= + d(u) + d(v) - 2 = -2

2(k - 1) + 2 = 2k =

Hence by induction we get that the sum of the degrees of the vertices of the graph G is twice the
numbers of edges.
6
BC0052 Theory of Computer Science Set -1

6. Prove that T is a tree there is one and only one path between every pair of vertices
Part 1: Suppose T is a tree. Then T is a connected graph and contains no circuits.
Since T is connected, there exists at least one path between every pair of vertices in T.
Suppose that between two vertices a and b of T, there are two distinct paths.
Now, the union of these two paths will contain a circuit in T, a contradiction (since T contains no
circuits).
This shows that there exists one and only one path between a given pair of vertices in T.
Part 2: Let G be a graph.
Assume that there is one and only one path between every pair of vertices in G.
This shows that G is connected.
If possible suppose that G contains a circuit.
Then there is at least one pair of vertices a, b such that there are two distinct paths between a and b.
But this is a contradiction to our assumption.

So G contains no circuits. Thus G is a tree

Vous aimerez peut-être aussi