0% found this document useful (0 votes)
9 views

Assignment 2 Solution 1

Uploaded by

hhi33027
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Assignment 2 Solution 1

Uploaded by

hhi33027
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

lOMoAR cPSD| 46205556

FAST- National University of Computer and Emerging


Sciences, Karachi.
FAST School of Computing
Assignment # 3 -- Solution, Fall 2021.
CS1005-Discrete Structures
Instructions: Max. Points: 100
1- This is hand written assignment.
2- Just write the question number instead of writing the whole question.
3- You can only use A4 size paper for solving the assignment.

1. Determine whether the graph shown in figure i to iv has directed or undirected edges, whether
it has multiple edges, and whether it has one or more loops. Use your answers to determine
the type of graph.
Solution:
i) It has undirected edges. It has
multiple edges.
It has no loops.
It is undirected Multigraph.

ii) It has undirected edges. It has


no multiple edges.
It has no loops.
It is undirected simple graph.
iii) It has
undirected
edges.
It has multiple edges.
It has three loops.
It is undirected Pseudo graph.

iv) It has directed edges. It


has multiple edges.
It has two loops.
It is directed Multi graph.

2. The intersection graph of a collection of sets A1, A2,…, An is the graph that has a vertex for
each of these sets and has an edge connecting the vertices representing two sets if these
sets have a nonempty intersection. Construct the intersection graph of these collections of
sets.
i) A1 = {0, 2, 4, 6, 8}, A2 = {0, 1, 2, 3, 4}, A3 = {1, 3,
5, 7, 9}, A4 = {5, 6, 7, 8, 9}, A5 = {0, 1, 8, 9} ii) A1
= {…,−4,−3,−2,−1, 0}, A2 = {…,−2,−1, 0, 1, 2,…},
A3 = {…,−6,−4,−2, 0, 2, 4, 6,…}, A4 = {…,−5,−3,−1,
1, 3, 5,…},
A5 = {…,−6,−3, 0, 3, 6,…}
Solution:
lOMoAR cPSD| 46205556

i) ii)

3. (a) Find the number of vertices, the number of edges, and the degree of each vertex in the
given undirected graph. Also find the neighborhood
vertices of each vertex in given graphs. i) Number of
Vertices: 5 Number of edges:13 Degree of vertices:
deg(a) = deg(b) = deg(c) = 6, deg(d) = 5, deg(e) = 3.
Neighborhood Vertices:
N(a) = {a, b, e}, N(b) = {a, c, d, e}, N(c) = {b, c, d}, N(d) =
{b, c, e}, N(e) = a, b, d}

ii) Number of Vertices: 9 Number of edges:12 Degree of


vertices:
deg(a) =3, deg(b) =2, deg(c) = 4, deg(d) = 0, deg(e) = 6.
deg(f) =0, deg(g) =4, deg(h) = 2, deg(i) = 3. Neighborhood
Vertices:
N(a) = {c, e, i}, N(b) = {e, h}, N(c) = {a, e, g, i}, N(d) = ,
N(e) = {a, b, c, g}, N(f) = , N(g) = {c, e}, N(h) = {b, i}, N(i) = {a, c, h}.

(b) Determine the number of vertices and edges and find the in-degree and out-degree of each
vertex for the given directed multigraph.
i) In-degree of a vertices
deg−(a) = 6, deg−(b) = 1, deg−(c) = 2, deg−(d) = 4, deg−(e) = 0.

Out-degree of a vertices deg+(a) = 1, deg+(b) = 5, deg+(c) = 5,


deg+(d) = 2, deg+ (e) = 0.

ii) In-degree of a vertices


deg (a) = 2, deg (b) = 3, deg (c) = 2, deg−(d) = 1.
− − −

Out-degree of a vertices deg+(a) = 2, deg+(b) = 4, deg+(c) = 1,


deg+(d) = 1.

4. (a) Suppose that a new company has five employees: Zamora, Agraharam, Smith, Chou, and
Macintyre. Each employee will assume one of six responsibilities: planning, publicity, sales,
marketing, development, and industry relations. Each employee is capable of doing one or
more of these jobs: Zamora could do planning, sales, marketing, or industry relations;
Agraharam could do planning or development; Smith could do publicity, sales, or industry
relations; Chou could do planning, sales, or industry relations; and Macintyre could do
planning, publicity, sales, or industry relations. Model the capabilities of these employees
using appropriate graph. Solution: Bipartite Graph
lOMoAR cPSD| 46205556

(b) Suppose that there are four employees in the computer support group of the School of
Engineering of a large university. Each employee will be assigned to support one of four
different areas: hardware, software, networking, and wireless. Suppose that Ping is qualified
to support hardware, networking, and wireless; Quiggley is qualified to support software and
networking; Ruiz is qualified to support networking and wireless, and Sitea is qualified to
support hardware and software. Use appropriate graph to model the four employees and their
qualifications. Solution: Bipartite Graph

5. Find which of the following graphs are bipartite. Redraw the bipartite graphs so that their
bipartite nature is evident. Also write the disjoint set of vertices.
i) ii) iii) iv)

Solution:
(a) Not bipartite (since a is adjacent to b & f vertices)
(b)Bipartite (A (V1, V3, V5) & B (V2, V4, V6))
(c) Not bipartite (since V4 & V5 are adjacent vertices)
(d)Not Bipartite (since b is adjacent to d & e vertices)

6. Draw a graph with the specified properties or show that no such graph exists.
a) A graph with four vertices of degrees 1, 1, 2, and 3
b) A graph with four vertices of degrees 1, 1, 3, and 3
c) A simple graph with four vertices of degrees 1, 1, 3, and 3
Solution:
a) No such graph is possible. By Handshaking theorem, the total degree of a graph is
even.
But a graph with four vertices of degrees 1, 1, 2, and 3 would have a total degree of 1 + 1 + 2 +
3 = 7, which is odd. b) Let G be any of the graphs shown below.
lOMoAR cPSD| 46205556

In each case, no matter how the edges are labeled, deg(a) = 1, deg(b) = 1, deg(c) =3, and
deg(d) = 3.
c) There is no simple graph with four vertices of degrees 1, 1, 3, and 3.
7. a) In a group of 15 people, is it possible for each person to have exactly 3 friends? Explain.
(Assume that friendship is a symmetric relationship: If x is a friend of y, then y is a friend of
x.) Solution:
By using Handshaking theorem.
No! there is no graph possible, such that 15 vertices have degree 3. Since (15 * 3) ≠ 2e.
b) In a group of 4 people, is it possible for each person to have exactly 3 friends?
Why? Solution:
By using Handshaking theorem.
Yes! there is graph possible, such that 4 vertices have degree 3. Since (4 * 3) = 2e.

8. (a) Find the union of the given pair of simple graphs. (Assume edges with the same endpoints
are the same.)
i) ii)

Solution:
i) ii)

b) How many vertices does a regular graph of degree four with 10 edges
have? Solution:
lOMoAR cPSD| 46205556

9. For given pair (G, G’) of graphs. Determine whether they are isomorphic. If they are, give
function g: V (G) →V (G/) that define the isomorphism. If they are not, give an invariant for
graph isomorphism that they do not share. i)

Solution: Both graph G and G’ are satisfying all the invariant. Hence, they are isomorphic.
Function: g(V1) = W2, g(V2) = W3 g(V3) = W1 g(V4) = W5 g(V5) = W4
ii)

Solution: Both graph G and G’ are satisfying all the invariant. Hence, they are isomorphic.
Function: g(V1) = U5, g(V2) = U2 g(V3) = U4 g(V4) = U3 g(V5) = U1 g(V6) = U6
iii)

Solution: Both graph G and G’ are satisfying all the invariant. Hence, they are isomorphic.
Function: g(V1) = U5, g(V2) = U4 g(V3) = U3 g(V4) = U2 g(V5) = U7
g(V6) = U1 g(V7) = U6
iv)
lOMoAR cPSD| 46205556

Solution: Graph G has no vertex of degree 4 where G’ has vertex V2 with degree 4. Hence, they
are not isomorphic.
10. Find the length of a shortest path between a and z in the given weighted graph by using
Dijkstra’s algorithm. i)

ii)
lOMoAR cPSD| 46205556

N D(b) D(c) D(d) D(e) D(f) D(g) D(z)


a 4,a 3,a ∞ ∞ ∞ ∞ ∞
ac 6,c 9,c ∞ ∞ ∞
acb 6,c 9,c ∞ ∞ ∞
acbd 7,d 11,d ∞ ∞
acbde 11,d 12,e ∞
acbdef 12,e 18,f
acbdefg 16,g
acbdefgz 4,a 3,a 6,c 7,d 11,d 12,e 16,g
11. Imagine that the drawing below is a map showing four cities and the distances in
kilometers between them. Suppose that a salesman must travel to each city exactly once,
starting and ending in city A. Which route from city to city will minimize the total distance
that must be traveled?
i) ii)

i) Solution:
Hamiltonian Circuit are: ABCDA = 125; ABDCA = 140; ACBDA =
Hence ABCDA = 125 is the minimum distance 155.
travelled. ii) Solution:
Hamiltonian Circuit are: ABCDA = 97; ABDCA = 108; ACBDA =
Hence ABCDA = 97 is the minimum distance travelled. 141.

12. (a) The following is a floor plan of a house. Is it possible to enter the house in room A,
travel through every interior doorway of the house exactly once, and exit out of room E?
If so, how can this be done?

Solution:
Yes! Path: A
→H→G→B→C→D→G→F→E

(b)The floor plan shown below is for a house that is open for public viewing. Is it possible
to find a trail that starts in room A, ends in room B, and passes through every interior
doorway of the house exactly once? If so, find such a trail.
lOMoAR cPSD| 46205556

13. Find Hamiltonian circuits AND Path for those graphs that have them. Explain why the other
graphs do not.
i) ii) iii)

i) Solution:
Hamiltonian Circuit: V0, V1, V2, V6, V5, V4,
V7, V3, V0 Hamiltonian Path: V0, V1, V2, V6,
V5, V4, V7, V3 ii) Solution:
Hamiltonian Circuit: doesn’t
exist Hamiltonian Path: b, c, f,
g, h, e, a, d iii) Solution:
Hamiltonian Circuit: d, c, b, a, g, f, e, d
Hamiltonian Path: d, c, b, a, g, f, e

14. a) Determine which of the graphs have Euler circuits. If the graph does not have an Euler
circuit, explain why not. If it does have an Euler circuit, describe one.
i) ii)

i) Solution: All vertices have even degree so


circuit exists. Euler Circuit: V1, V2, V5, V4, V5, V2,
V3, V4, V1 ii) Solution:
Euler Circuit do not exist because all vertices don’t have even degree.
lOMoAR cPSD| 46205556

(b)Determine whether there is an Euler path from u to w. If the graph does not have an Euler
path, explain why not. If it does have an Euler path, describe one.
i) ii)

i) Solution:
Euler Path doesn’t exist because four vertices have odd degree.
ii) Solution: Euler Path exists because exact two vertices have odd degree.
Euler path: U, V1, V0, V7, U, V2, V3, V4, V2, V6, V5, W, V6, V4, W
15. (a) Use an incidence matrix to represent the graph shown below.
i) ii)
Solution: i) ii)

(b)Draw a graph using below given incidence matrix.


i) ii)

Solution:
i) ii)

16. Use an adjacency list and adjacency matrix to represent the given graph. i)
lOMoAR cPSD| 46205556

Initial Terminal Vertices


Vertex
a a, b, c, d
b d
c a, b
d b, c, d

(ii)

Initial Terminal Vertices


Vertex
a b, d
b a, c, d, e
c b, c,
d a, e
e c, e
iii)
Vertex Adjacent Vertices
a b, d
b a, c
c b, d
d a, c

iv)

Vertex Adjacent Vertices


a a, c, d
b b, c, d
c a, b, c
d a, c, d

17. Consider the tree shown at right with root a.

Solution:
i) What is the level of n? Level of n is 3.
ii) What is the level of a? Level of a is 0.
iii) What is the height of this rooted Height of this rooted tree is 5
tree?
lOMoAR cPSD| 46205556

iv) What are the children of n? u & v are the children of n.


v) What is the parent of g? d is the parent of g.
vi) What are the siblings of j? k & l are the siblings of j.
vii) What are the descendants of f? m, s, t, x & y are the descendants of f.
viii) What are the internal nodes? a, b, e, k, c, f, m, t, d, h, i, n, o & v are the
internal nodes.
ix) What are the ancestors of z? v, n, h, d & a are the ancestors of z.
x) What are the leaves? j, l, q, r, s, x, y, g, p, u, w & z are the leaves.

18. Use Prim’s algorithm to find a minimum spanning tree starting from V0 for given graphs.
Indicate the order in which edges are added to form
each tree. i) Solution: MST Cost = 61
(V0,V5) = 4, (V5,V6) = 8, (V4,V5) = 10,
(V3,V4) = 2, (V1,V3) = 5, (V6,V7) = 13,
(V2,V7) = 19.

ii)

Solution: MST Cost = 37


(V0,V1) = 4, (V0,V8) = 8, (V7,V8) = 1,
(V6,V7) = 2, (V3,V6) = 4, (V2,V3) = 2,
(V3,V4) = 7, (V4,V5) = 9,

19. Use Kruskal’s algorithm to find a minimum spanning tree for given graphs. Indicate the order
in which edges are added to form each tree.
i) ii)

i) Solution: MST cost = 15 Order of edges added is:


(d, f) =1, (a, c) =2, (a, b) =3, (b, c) =3,
(c, d) =4, (d, e) =5, (c, e) =6, (e, f) =6
lOMoAR cPSD| 46205556

ii) Solution: MST cost = 28 Order of edges added is:


(g, f) =1, (a, b) =3, (a, e) =3, (a, g) =4,
(b, e) =4, (e, f) =4, (g, e) =5, (b, c) =7
20. (a)
(c, e) (c, d) =10, (d, e) =11, (d, f) i) Build a binary search tree for the
=7, =12
word’s banana, peach, apple, pear,
coconut, mango, and papaya using alphabetical order.
ii) Build a binary search tree for the word’s oenology, phrenology, campanology,
ornithology,
ichthyology, limnology, alchemy, and astrology using alphabetical order.
Solution:
i) ii)

(b) Represent these expressions using binary trees.


(i) (x + xy) + (x / y)
(ii) x + ((xy + x) / y)
Solution:
i) ii)

21. Determine the order in which preorder, Inorder and Postorder traversal visits the
vertices of the given ordered rooted tree.
i) ii)
lOMoAR cPSD| 46205556

Solution:
i)
Preorder: a b e k l m f g n r s c d h o I j p q
Inorder: k e l m b f r n s g a c o h d i p j q
Postorder: k l m e f r s n g b c o h I p q j d a
ii)
Preorder: a b d e i j m n o c f g h k l p
Inorder: d b i e m j n o a f c g k h p l
Postorder: d i m n o j e b f g k p l h c a

22. (a) How many edges does a tree with 10000 vertices have? Solution:
A tree with n vertices has n – 1 edge. Hence 10000 – 1 = 9999 edges.
(b) How many edges does a full binary tree with 1000 internal vertices have?
Solution:
A full binary tree has two edges for each internal vertex. So, we’ll just multiply the
number of internal vertices by the number of edges. Hence 1000 * 2 = 2000 edges.
(c) How many vertices does a full 5-ary tree with 100 internal vertices have?
Solution:

23. a) Write these expressions in Prefix and Postfix notation: i) (x + xy) + (x / y)


Solution:
Prefix: + + x * x y / x y
Postfix: x x y * + x y /
+ ii) x + ((xy + x) / y)
Solution:
Prefix: + x / + * x y x y
Postfix: x x y * x + y / +
b) i) What is the value of this prefix expression + – ↑ 3 2 ↑ 2 3 / 6 – 4 2
Solution: 4
ii) What is the value of this postfix expression 4 8 + 6 5 – * 3 2 – 2 2
+ * / Solution: 3

24. Answer these questions about the rooted tree illustrated.

i) Is the rooted tree a full m-ary tree?


Solution: It is not a full m-ary tree for any m because some
of its internal vertices have two children and others have
three children. ii) Is the rooted tree a balanced m-ary tree?
Solution: It is not balanced m-ary tree because it has
leaves at levels 2, 3, 4 and 5.

iii) Draw the subtree of the tree that is rooted at


a) c. b) f. c) q.
Solution:
a) b) c)

25. Find a spanning tree for the graph shown by removing edges in simple circuits. Write
down the removed edges.
(i) ii) iii)
Solution:

i) ii) iii)

13
lOMoAR cPSD| 46205556

26. (--------------------------)
27. Let R be the following relation defined on the set {a, b, c, d}:
R = {(a, a), (a, c), (a, d), (b, a), (b, b), (b, c), (b, d), (c, b), (c, c), (d, b), (d, d)}
Determine whether R is:
(a) Reflexive: (b) Symmetric (c)
Antisymmetric
(d) Transitive (e) Irreflexive (f) Asymmetric
Solution:
(a) R is reflexive because R contains ( a, a ), ( b, b ), ( c, c ), and ( d, d ).
(b)R is not symmetric because R contains ( a, c ) but not ( c, a ) ∈ R .
(c) R is not antisymmetric because both ( b, c ) ∈ R and ( c, b ) ∈ R , but b = c.
(d)R is not Transitive because both ( a, c ) ∈ R and ( c, b ) ∈ R , but not ( a, b ) ∈ R.
(e) R is not irreflexive because R contains ( a, a ), ( b, b ), ( c, c ), and ( d, d ).
(f) R is not Asymmetric because R is not Antisymmetric.

28. List the ordered pairs in the relation R from A = {0, 1, 2, 3, 4} to B = {0, 1, 2, 3}, where (a,
b) ∈
R if and only if
a) a = b. b) a + b = 4. c) a > b.
d) a | b. e) gcd(a, b) = 1. f) lcm (a, b) =
2.
Solution:
a) { (0,0), (1, 1), (2, 2), (3, 3) }
b) { (1, 3), (2, 2), (3, 1), (4, 0) }
c) { (1, 0), (2, 0), (3, 0), (4, 0), (2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3) }
d) { (1, 0), (2, 0), (3, 0), (4, 0), (1, 1), (1,2), (2,2), (1,3), (3,3) }
e) { (1,0), (0,1), (1,1), (1,2), (1,3), (2,1), (3,1), (4,1), (2,3),(3,2),(4,3) } f) { (1,2), (2,1), (2,2) }
29. List all the ordered pairs in the relation R = {(a, b) | a divides b} on the set {1,
2, 3, 4, 5, 6}. Display this relation as Directed Graph(digraph), as well in
matrix form. mSolution:
R= { (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (2, 2), (2, 4), (2, 6), (3, 3), (3, 6), (4, 4), (5, 5), (6, 6)
}

𝟏 𝟏 𝟏 𝟏 𝟏 𝟏
𝖥𝟎 𝟏 𝟎 𝟏 𝟎 𝟏1 𝟎 𝟎 𝟏 𝟎𝟎𝟏
𝟎𝟎 𝟎 𝟏𝟎𝟎
I𝟎𝟎 𝟎 𝟎 𝟏 𝟎I
[𝟎𝟎 𝟎 𝟎 𝟎 𝟏]

30. For each of these relations on the set {1, 2, 3, 4}, decide whether it is
reflexive, whether it is symmetric, whether it is antisymmetric, and whether
it is transitive.
lOMoAR cPSD| 46205556

a) { (2, 2), (2, 3), (2, 4), (3, 2), (3, 3), (3, 4) }
Solution:
a. R is not reflexive: It doesn’t contain (1,1) and (4,4).
b. R is not symmetric because R contains (2, 4) but not (4, 2) ∈ R.
c. R is not antisymmetric: we have (2,3) and (3,2) but 2 ≠ 3.
d. R is Transitive because for any numbers a, b, and c, if (a, b), (b, c) ∈ R then (a,
c) ∈ R.

b) { (1, 1), (1, 2), (2, 1), (2, 2), (3, 3), (4, 4) }
Solution:
a. R is reflexive: It contains (1,1) ,(2,2), (3,3) and (4,4).
b. R is symmetric because (a,b) and (b,a) ∈ R.
c. R is not antisymmetric: we have (1,2) and (2,1) but 1 ≠ 2.
d. R is Transitive because for any numbers a, b, and c, if (a, b), (b, c) ∈ R then
(a, c) ∈ R.

c) { (2, 4), (4, 2) }


Solution:
a. R is not reflexive: It doesn’t contain (1,1) ,(2,2), (3,3) and (4,4).
b. R is symmetric because R contains (2, 4) and (4, 2) ∈ R.
c. R is not antisymmetric: we have (2,4) and (4,2) but 2 ≠ 4.
d. R is not Transitive because (2,4), (4, 2) ∈ R but not (2,2) ∈ R.

d) { (1, 2), (2, 3), (3, 4) }


Solution:
a. R is not reflexive: It doesn’t contain (1,1) ,(2,2), (3,3) and (4,4).
b. R is not symmetric because (1,2) ∈ R but not (2,1) ∈ R.
c. R is antisymmetric: we have (a,b) but not (b,a) ∈ R.
d. R is not Transitive because (1,2), (2, 3) ∈ R but not (1,3) ∈ R.

e) {(1, 1), (2, 2), (3, 3), (4, 4)}


Solution:
a. R is reflexive: It contains (1,1) ,(2,2), (3,3) and (4,4).
b. R is symmetric because R contains (a,b) and (b,a) ∈ R.
c. R is antisymmetric: we have (a,b) and (b,a) ∈ R then a = b.
d. R is Transitive because for any numbers a, b, and c, if (a, b), (b, c) ∈ R then
(a, c) ∈ R.

f) {(1, 3), (1, 4), (2, 3), (2, 4), (3, 1), (3, 4)}
Solution:

a. R is not reflexive: It doesn’t contain (1,1) ,(2,2), (3,3) and (4,4).


b. R is not symmetric because (1,4) ∈ R but not (4,1) ∈ R.
c. R is not antisymmetric: we have (1,3) and (3,1) ∈ R but 1 ≠ 3.
d. R is not Transitive because we have (1,3) and (3,1) ∈ R but not (1,1) ∈ R.

31. Determine whether the relation R on the set of all people is reflexive,
symmetric, antisymmetric, Asymmetric, irreflexive and/or transitive,
where (a, b) ∈ R if and only if: a) a is taller than b. Solution:
lOMoAR cPSD| 46205556

b) a and b were born on the same day.


Solution:

c) a
has the same first name as b.
Solution:

d) a and b have a common grandparent.


Solution:

(a) Antisymmetric, Irreflexive, Asymmetric and Transitive


lOMoAR cPSD| 46205556

(b) Reflexive, Symmetric and Transitive


(c) Reflexive, Symmetric and Transitive
(d) Reflexive and Symmetric

32. Give an example of a relation on a set that is


a) both symmetric and antisymmetric.
Solution:
{ (1,1), (2,2), (3,3), (4,4) }

b) neither symmetric nor antisymmetric.


Solution:
{ (1,2), (2,1), (3,4) }

33. Consider these relations on the set of real


numbers: A={1,2,3}
R1 = {(a, b) ∈ R | a > b}, the “greater than” relation,
R2 = {(a, b) ∈ R | a ≥ b}, the “greater than or equal to “relation,
R3 = {(a, b) ∈ R | a < b}, the “less than” relation,
R4 = {(a, b) ∈ R | a ≤ b}, the “less than or equal to “relation,
R5 = {(a, b) ∈ R | a = b}, the “equal to”
relation, R6 = {(a, b) ∈ R | a ≠ b}, the
“unequal to” relation.

Find:
a) R2 𝖴 R4. b) R3 𝖴 R6. c) R3 ∩ R6. d) R4 ∩
R6.
e) R3 − R6. f) R6 − R3. g) R2 ⊕ R6. h) R3 ⊕
R5.
i) R2 ◦ R1. j) R6 ◦ R6.
Solution:
R1= { (2,1), (3,1), (3,2) } R2= { (1,1), (2,2), (3,3), (2,1), (3,1), (3,2) }
R3= { (1,2), (1,3), (2,3) } R4= { (1,1), (2,2), (3,3), (1,2), (1,3), (2,3) }
R5= { (1,1), (2,2), (3,3) } R6= {(1,2), (1,3), (2,1), (2,3), (3,1), (3,2) }

a) R2 𝖴 R4 = { (1,1), (2,2), (3,3), (2,1), (3,1), (3,2) (1,2), (1,3), (2,3) }


b) R3 𝖴 R6= {(1,2), (1,3), (2,1), (2,3), (3,1), (3,2) }
c) R3 ∩ R6 = { (1,2), (1,3), (2,3) }
d) R4 ∩ R6 = { (1,2), (1,3), (2,3) }
e) R3 − R6 = { } OR Φ
f) R6 − R3 = { (2,1), (3,1), (3,2) }
g) R2 ⊕ R6 = { (1,1), (2,2), (3,3), (1,2), (1,3), (2,3) }
h) R3 ⊕ R5 = { (1,1), (2,2), (3,3), (1,2), (1,3), (2,3) } i) R2 ◦
R1 = { (2,1), (3,1), (3,2) }
j) R6 ◦ R6 = { (1,1), (2,2), (3,3), (2,1), (3,1), (3,2) (1,2),
(1,3), (2,3) }
34. (a) Represent each of these relations on { 1 , 2 , 3 } with a matrix(with the elements
of this set listed in increasing order).
i) { (1 , 1), ( 1 , 2), ( 1 , 3) }
𝟏 𝟏 𝟏
Solution: [𝟎 𝟎 𝟎]
𝟎 𝟎 𝟎
lOMoAR cPSD| 46205556

ii) { (1 , 2), ( 2 , 1), ( 2 , 2)


,( 3 , 3) }
𝟎 𝟏 𝟎
Solution: [𝟏 𝟏 𝟎]
𝟎 𝟎 𝟏
iii) { (1 , 1), (1 , 2), ( 1 , 3) , ( 2 , 2), ( 2 ,
3) ,( 3 , 3) }
𝟏 𝟏 𝟏
Solution: [𝟎 𝟏 𝟏]
𝟎 𝟎 𝟏

iv) { ( 1 , 3), ( 3 , 1) 𝟏
} 𝟎]
𝟎 𝟎 𝟎
Solution: [𝟎 𝟎 𝟏
𝟎

(b) List the ordered pairs in the relations on { 1 , 2 , 3 } corresponding to these


matrices(where rows and columns correspond to the integers listed in increasing
order).
𝟏 𝟎 𝟏
(i) [𝟎 𝟏 𝟎] Solution: R = { (1,1), (1,3), (2,2), (3,1), (3,3) }
𝟏 𝟎 𝟏
𝟎 𝟏 𝟎
(ii) [𝟎 𝟏 𝟎] Solution: R = { (1,2), (2,2), (3,2) }
𝟎 𝟏 𝟎
𝟏 𝟏 𝟏
(iii) [𝟏 𝟎 𝟏] Solution: R = { (1,1), (1,2), (1,3), (2,1), (2,3),
(3,1),(3,2), (3,3) }
𝟏 𝟏 𝟏

35. (a) Suppose that R is the relation on the set of strings of English letters such that aRb if
and only if l(a) = l(b), where l(x) is the length of the string x. Is R an equivalence relation?
Solution:
Show that all of the properties of an equivalence relation hold.
• Reflexivity: Because l(a) = l(a), it follows that aRa for all strings a.
• Symmetry: Suppose that aRb. Since l(a) = l(b), l(b) = l(a) also holds and bRa.
• Transitivity: Suppose that aRb and bRc. Since l(a) = l(b),and l(b) = l(c), l(a) = l(a)
also holds and aRc.

(b) Let m be an integer with m > 1. Show that the relation R = {(a,b) | a ≡ b (mod m)}
is an equivalence relation on the set of integers.
Solution:
Recall that a ≡ b (mod m) if and only if m divides a − b.
• Reflexivity: a ≡ a (mod m) since a − a = 0 is divisible by m since 0 = 0 ∙ m.
• Symmetry: Suppose that a ≡ b (mod m). Then a − b is divisible by m, and so a − b
= km, where k is an integer. It follows that b − a = (− k) m, so b ≡ a (mod m).
• Transitivity: Suppose that a ≡ b (mod m) and b ≡ c (mod m). Then m divides both
a − b and b − c. Hence, there are integers k and l with a − b = km and b − c = lm.
We obtain by adding the equations: a − c = (a − b) + (b − c) = km + lm = (k + l) m.
Therefore, a ≡ c (mod m).
lOMoAR cPSD| 46205556

36. (a) Find the first five terms of the sequence for each of the following general terms
where n >0.
(i) 𝟐𝒏 − 𝟏
Solution:1,2,4,8,16 are the first five terms of the given sequence.

𝟑
(ii) 𝟏𝟎 − 𝒏
𝟐
Solution:
𝟏𝟏 𝟓
𝟏𝟕 , 𝟕, , 𝟒, are the first five terms.
𝟐 𝟐 𝟐

𝒏
(iii) (−𝟏)
𝒏𝟐
Solution:
𝟏 𝟏 𝟏 𝟏
−𝟏, , − , , − are the first five terms.
𝟒 𝟗 𝟏𝟔 𝟐𝟓

(iv) 𝟑𝒏+𝟒
𝟐𝒏−𝟏
𝟏𝟎 𝟏𝟑 𝟏𝟔 𝟏𝟗
Solution: 𝟕, , , , are the first five terms.
𝟑𝟓𝟕𝟗

(b) Identify the following Sequence as Arithmetic or Geometric Sequence then find the
indicated term.

(i) -15, -22, -29, -36, .................... ; 11th term.


Solution:
Here common difference (d) = −7
𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅; 𝑻𝟏𝟏 = −𝟏𝟓 + (𝟏𝟏 − 𝟏)(−𝟕) = −𝟖𝟓

(ii)a - 42b, a - 39b, a - 36b, a - 33b, ….; 15th term.


Solution:
Here common difference (d) = 3b
𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅 ; 𝑻𝟏𝟓 = 𝒂 − 𝟒𝟐𝒃 + (𝟏𝟓 − 𝟏)(𝟑𝒃) = 𝒂
(iii) 4, 3, 𝟗 , ...... ; 17th term
𝟒
Solution:
Here common ratio (r) = 𝟑
𝟒 𝟑 𝟏𝟕−𝟏 = 𝟑𝟏𝟔 𝑻 =
𝒂𝒓𝒏−𝟏; 𝑻
𝒏 𝟏𝟕 = 𝟒( 𝟒) 𝟒𝟏𝟓

(iv) 32, 16, 8, ….; 9th term


Solution:
Here common ratio (r) = 𝟏
𝟐 𝟏
𝑻 = 𝒂𝒓𝒏−𝟏; 𝑻 𝟗−𝟏 = 𝟏

𝟐
𝒏 𝟏𝟕 = 𝟑𝟐( )
𝟖
lOMoAR cPSD| 46205556

37. (a) Find the G.P in which:


𝟏
(i) T3 = 10 and T5 = 𝟐
𝟐
Solution:
Since 𝑻𝒏 = 𝒂𝒓𝒏−𝟏
𝟓
𝑻𝟑 = 𝒂𝒓𝟐 = 𝟏𝟎 ----(i) = 𝒂𝒓𝟒 = 𝟐 -----(ii)
𝑻𝟓 𝟏
Now, dividing (ii) by dividing (i), we get r = ± and putting it in (i) we get a = 40.
𝟐
Now the required G.P is 40,20,10,5, 𝟓 ,... OR 40,−20,10, −5, 𝟓 , …...
𝟐 𝟐
𝟔𝟒
(ii) T5 = 8 and T8 = −
𝟐𝟕
Solution:
Since 𝑻𝒏 = 𝒂𝒓𝒏−𝟏
lOMoAR cPSD| 46205556

𝑻𝟓 = 𝒂𝒓𝟒 = 𝟖 ----(i)
𝑻𝟖
𝟔𝟒 -------
= 𝒂𝒓𝟕 = − (ii)
𝟐𝟕
lOMoAR cPSD| 46205556

𝟐
Now, dividing (ii) by dividing (i) we get r = − and putting it in (i) we get a = 𝟖𝟏.
𝟑 𝟐
Now the required G.P is 𝟖𝟏 , −𝟐𝟕, 𝟏𝟖, −𝟏𝟐, 𝟖,...
𝟐

(b) Find the A.P in which:

(i) T4 = 7 and T16 = 31


Solution:
Since 𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅 ;
𝑻𝟒 = 𝒂 + 𝟑𝒅 = 𝟕……(i) 𝑻𝟏𝟔 = 𝒂 + 𝟏𝟓𝒅 = 𝟑𝟏……(ii)
Now subtracting (ii) from (i), we get d = 2 and putting it in (i) we
get a = 1. Now the required A.P is 1,3,5,7,9, 11,...

(ii) T5 = 86 and T10 =


146 Solution:
Since 𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅 ;
𝑻𝟓 = 𝒂 + 𝟒𝒅 = 𝟖𝟔……(i) 𝑻𝟏𝟎 = 𝒂 + 𝟗𝒅 = 𝟏𝟒𝟔……(ii) Now
subtracting (ii) from (i), we get d = 12 and putting it in (i) we
get a = 38. Now the required A.P is 38,50,62,74,86,…

38. (a) How many numbers are there between 256 and 789 that are divisible by 7. Also find
their sum.
Solution:
First, we find the A.P with the common difference (d)= 7 259,266,273,
280, ,……. 784
Since 𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅 ;
𝟕𝟖𝟒 = 𝟐𝟓𝟗 + (𝒏 − 𝟏)(𝟕) ;
n = 76.
𝒏
Now for Sum; 𝑺𝒏 = 𝟐 [𝟐𝒂 + (𝒏 − 𝟏)𝒅];

𝟕𝟔
𝑺𝟕𝟔 = 𝟐 [𝟐(𝟐𝟓𝟗) + (𝟕𝟔 − 𝟏)(𝟕)] = 39,634.

𝟐−𝒏+𝟏

(b) Find the sum to n terms of an A.P whose first term is and the last term is 𝒏 𝟏 .
𝒏 𝒏
Solution:
𝒏
------
Since, 𝑺𝒏 = 𝟐 [𝟐𝒂 + (𝒏 − 𝟏)𝒅] (i)
st
1 we have to find “d”
Now, 𝑻𝒏 = 𝒂 + (𝒏 − 𝟏)𝒅
𝒏𝟐 − 𝒏 + 𝟏 𝟏
= + (𝒏 − 𝟏)𝒅
𝒏 𝒏
Finally, d = 1. Hence putting it in we get,
𝒏𝟐−𝒏+𝟐 𝑺𝒏
= 𝟐
.
lOMoAR cPSD| 46205556

39. (a) Use summation notation to express the sum of the first 100 terms of the sequence {aj
}, where
𝟏 aj = for j = 1,
2, 3….
𝖩̅

Solution: 𝟏𝟎𝟎 𝟏
The lower limit for the index of summation is 1, and the upper limit is 100. We write this sum as

𝒋 𝟏 𝒋

(b) What is the value of:

Solution:
= (−1)4 + (−1)5 + (−1)6 + (−1)7 +
8
(−1) = 1 + (−1) + 1 + (−1) + 1 = 1.

(ii) ∑𝟓 (𝒋)𝟐 ⋅
𝒋=𝟏
Solution:
= 12 + 22 + 32 + 42 +
52 = 1 + 4 + 9 + 16 + 25 =
55.

40. Find the first six terms of the sequence defined by each of these recurrence
relations and initial conditions.

a) an = −2an−1, a0 = −1
Solution:

b) an = an−1 − an−2, a0 = 2, a1 =
−1 Solution:

c) an = 3a2n−1, a0 = 1 Solution:
lOMoAR cPSD| 46205556

d) an = nan−1 + a2n−2, a0 = −1, a1


= 0 Solution:

41. As we have discussed, the practical application of all the topics in the class. Now
you are required to submit at least two real world applications of the following topics.
(a) Propositional Logic

State-space search is the issue of testing whether a state in a change framework


is reachable from at least one starting states. Change frameworks in the most
fundamental cases can be identified with diagrams, and the state-space search
issue for this situation is the s-t-reachability issue in charts.
Old style propositional rationale has been proposed as one response for state-
space look issues for amazingly gigantic charts, due to the possibility of
addressing and pondering colossal amounts of states with (by and large little)
recipes.
EXAMPLE:
A𝖠B represents the set {1100, 1101, 1110, 1111} and A∨B represents the set {0100,
0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111}.

Questions about the relations between sets represented as formulas can be


reduced to the basic logical concepts we already know, namely logical
consequence, satisfiability, and validity.

1. “Is φ satisfiable?” corresponds to “Is the set represented by φ non-empty?”


lOMoAR cPSD| 46205556

2. φ |= α corresponds to “Is the set represented by φ a subset of the set


represented by α?”.

3. “Is φ valid?” corresponds to “Is the set represented by φ the universal set?”
These connections allow using propositional formulas as a data structure in
some applications in which conventional enumerative data structures for sets
are not suitable because of the astronomic number of states. For example, if
there are 100 state variables, then any formula consisting of just one atomic
proposition represents a set of 2 99 =
633825300114114700748351602688 bit-vectors, which would require
7493989779944505344 TB in an explicit enumerative representation if each of
the 100-bit vectors was represented with 13 bytes (wasting only 4 bits in the 13th
byte.)

Web indexes utilizing Boolean hunts utilize consistent connectives.

• AND requires records coordinate the two terms

• OR returns records that coordinate either of the terms

• NOT (or now and then AND NOT) rejects a term

Basic Boolean search commands (quotes, AND and OR) are supported in
Google search, however Google defaults to AND searches automatically, so you
don't need to enter AND into the search box. Google search uses additional
symbols and words to refine searches such as "site:" to search a specific site
or domain or use $ in front of a number to search for a price.

(b) Predicates and quantifiers

Man-made consciousness is worried about information portrayal and rationales. Data


Representation is a sub zone of Artificial Intelligence stressed over getting, organizing,
and executing techniques for addressing information in PCs, and to surmise new
information reliant on the addressed information.
The predicate rationale is a piece of man-made brainpower which is relevant in the
field of mechanical technology, medication and it is utilized in smart database so as
to tackle some unpredictable issue.
EXAMPLE:
1. Mary loves everyone. [assuming D contains only
humans] x love (Mary, x)
lOMoAR cPSD| 46205556

Note: No further parentheses are needed here, and according to the syntax on
the handout, no further parentheses are possible. But “extra parentheses” are
in general considered acceptable, and if you find them helpful, I have no
objection. So I would also count as correct any of the following: x (love (Mary,
x)), ( x love (Mary, x)), ( x (love (Mary, x)))
Computer infers new conclusions in the same way using predicate logics and quantifiers.

Predicate Logic can be utilized to check legitimacy of a deduced conclusion. Using predicate
logic, we can validate inferences.
Consider these statements, of which the first three are premises and the fourth is a valid
conclusion.

“All hummingbirds are richly colored.”

“No large birds live on honey.”

“Birds that do not live on honey are dull in color.”

“Hummingbirds are small.”

Let P(x), Q(x), R(x), and S(x) be the statements “x is a hummingbird,” “x is large,” “x lives
on honey,” and “x is richly colored,” respectively. Assuming that the domain consists of
all birds, express the statements in the argument using quantifiers and P(x), Q(x), R(x),
and S(x).
Solution: We can express the statements in the
argument as ∀x(P(x) → S(x)).
¬∃x(Q(x) 𝖠 R(x)).
∀x(¬R(x)→¬S(x)).
∀x(P(x)→¬Q(x)).

(c) Sets

Clusters are likely the most well-known assortment type. A cluster stores an arranged
assortment of qualities. As I referenced before, the qualities put away in an exhibit are of a
similar sort. Sets and exhibits share a few highlights for all intents and purpose. The two
of them store an assortment of estimations of a similar kind. You can include and
evacuate components if the set or cluster is variable in this way exhibit is inferred for the
idea of set wherein each position has interesting worth simply like sets.
EXAMPLES:
Char array [6] = {‘a’, ‘b’, ‘c’, ‘d’, ‘e’,
‘f’}
In sets, this can be represented in the following way:
{(0,a), (1,b), (2,c), (3,d), (4,e),
(5,f)}

SQL is a domain-specific language used in programming and designed for managing data
held in a relational database management system, or for stream processing in a relational
data stream management system.
lOMoAR cPSD| 46205556

EXAMPLE:

1. Union:
This set operator is used to combine the outputs of two or more queries into a
single set of rows and columns having different records.
2. Union All:
This set operator is used to join the outputs of two or more queries into a single
set of rows and columns without the removal of any duplicates.
3. Intersect:
This set operator is availed to retrieve the information which is common in both
tables. The number of columns and data type must be same in intersect set
operator.
(d) Functions

Functions are frequently used in Physics and Mathematics.


EXAMPLE: You have given the velocity of rocket as 12000km/sec and the time required to
reach the moon is 3 days. You have to compute the distance between Earth and Moon.
Formula: S(t) = V*t
After changing the given information into SI units: S(259200) =
12000000*259200
S(259200) = 3.1104e+12 meters

Functions is the essential part of learning PC writing computer programs is tied in with taking
a contribution from the client then in the wake of experiencing some work restoring a worth
simply like taking an area and delivering a range.

We can make our own, “User Defined Function”. EXAMPLES:


An example of user defined function in c++ is:
void Print()
{
string name; cin>>name;
cout<<”Your Name is:
”<<name;
}

You might also like