Académique Documents
Professionnel Documents
Culture Documents
2014-2015
QUESTION BANK
UNIT-1
PART A
1. If A ans B are 2 sets with m and n elements respectively, what is the number of relations
Possible from A to B?
The number of relations possible from A to B is 2 mn
2. What are the 2 conditions for a relation to be a function?
Each element of A is associated to one and only one element of B, i.e. no element of A
is associated to two (or more) elements of B.
3. Define a function:Function f from set A to set B associates each element of A to unique (i.e. one and
only
one)
element
of
denoted
by
f: A B (read as f from A to B)
4. What are the 2 conditions for a relation to be a function?
If A and B be two non-empty sets,f be the relation from A to B then f is function from
A
to B iff:
7.What is the Cartesian product of the set A= {1,2} and the set B = {a,b,c}?
2014-2015
8.
10.
11.
12.Define the terms partial function, domain, codomain and total function:-
2014-2015
15.
16.
18.
2014-2015
20.
PART B
1. (a) Explain the principle of mathematical induction:(b) Explain why mathematical induction is a valid proof technique:(c) Proof:-
2.(a)
2014-2015
(c)
7.(a)
(b)
(c)
2014-2015
(b)
(c)
9.(a) What is the difference between a set and a sequence? What is used in representing the relationship
between two elements of a set set or sequence?
(b). What is the difference between proof by strong induction and induction?
(c) Why proving the correctness of recursive algorithms is easier.
10. Prove the following by induction:1 + 3 + 5+ +(2n 1) = n2
UNIT-2
PART-A
2014-2015
2014-2015
12. Construct truth tables for the following formulas. Use the truth tables to see if each formula is
valid or satisfiable:(a) P => P Q)
(b) ((P Q)
Q) P
13. Construct truth tables for the following formulas. Use the truth tables to see if each
formula is valid or satisfiable:St.Josephs College of Engineering
2014-2015
(a) (P Q)
P
Q
(b) P ( Q R)
(P Q)
(P R)
21. State whether the following are true or false, where x , and y range over the integers:- Show
your work
x . y.(2x y = 0)
y. x .(2x y = 0)
PART-B
1. (a) Build the Truth table for the following expression for the conjunction of implication and its
inverse. That is, for the following expression: (p q)
(!p !q).
2014-2015
(b) Show that (p q) (!p !q) is equivalent to (p q) (!p !q) from the Truth table constructed
in question 1 or using rules of propositional logic.
2. (a) What is Tautology? Explain with a simple example.
(b) Prove the following equivalence of De Morgans theorem by Truth Table. That is, show !(p q)
is equivalent to (!p !q)
3. (a) Use the following Conjunctive Normal Form (CNF) to explain the following terms: literal,
clause, and formula: (!a b c) (!a F) (!a !b !c)
(b) Express the following Disjunctive Normal Form formula into Conjunctive Normal Form using De
Morgans laws: (a !b !c) (a T) ( a b c)
(c) Is there a model for the above DNF? If there is one give its interpretation.
4.
Describe the following terms using the above DNF in question3 and draw the Venn diagram that
describes the relationship among these terms: Satisfiable, Valid, Unsatisfiable, and Falsifiable.
5. Write notes on SAT-solvers:6. Explain in detail about SLD resolution:7. Explain in detail about SLDNF resolution:8. Write notes on logic programming? Give an example program in PROLOG:9. Write down 8 laws of propositional logic that would help prove the propositions:10.Translate the following argument into a sequent in predicate logic using suitable set of predicate
symbols:
If there are tax payers, then all politicians are tax payers.
If there are any philanthropists, then all politicians are philanthropists.
So, if there are any tax paying philanthropists, then all politicians are philanthropists.
Prove the sequent in predicate logic.
UNIT-III
PART-A
1.What is the syntax of Lambda Calculus expression?
2.What is currying?
The strategy of nested one-variable functions used to represent multi-variable function is called
Currying.
St.Josephs College of Engineering
10
2014-2015
6. Define Eta-reduction:-
7. Define Delta-reduction:-
11
2014-2015
12
2014-2015
13.
16.Give the lambda expressions for the Boolean constants true and false:-
17.Give the lambda expressions for the set of logical operators: and or etc:-
13
2014-2015
PART-B
14
2014-2015
1.
2.
4.
15
2014-2015
5.
6.
7.
16
2014-2015
8.
17
2014-2015
UNIT: IV
PART A
1. Define a directed graph:A directed graph (or digraph) (V ,E) consists of a nonempty set of vertices V and a set of directed edges
(or arcs) E. Each directed edge is associated with an ordered pair of vertices. The directed edge
associated with the ordered pair (u, v) is said to start at u and end at v.
2. Define adjacency in a graph:Two vertices u and v in an undirected graph G are called adjacent (or neighbours) in G if u and v are
endpoints of an edge e of G. Such an edge e is called incident with the vertices u and v and e is said to
connect u and v.
3. Define neighborhood of a vertex in a graph:The set of all neighbours of a vertex v of G = (V ,E), denoted by N(v), is called the neighbourhood of v.
If A is a subset of V , we denote by N(A) the set of all vertices in G that are adjacent to at least one vertex
in A.
4. Define the degree of a vertex in a graph:The degree of a vertex in an undirected graph is the number of edges incident with it, except that a loop
at a vertex contributes twice to the degree of that vertex. The degree of the vertex v is denoted by deg (v).
5. Define complete and non-complete graphs:A complete graph on n vertices, denoted by Kn, is a simple graph that contains exactly one edge
between each pair of distinct vertices.
A simple graph for which there is at least one pair of distinct vertex not connected by an edge is called
non-complete.
6. Define a bipartite graph:-
18
2014-2015
A simple graph G is called bipartite if its vertex set V can be partitioned into two disjoint sets V1 and V2
such that every edge in the graph connects a vertex in V1 and a vertex in V2 (so that no edge in G
connects either two vertices in V1 or two vertices in V2). When this condition holds, we call the pair (V1,
V2) a bipartition of the vertex set V of G.
7. What is the procedure to check if a graph is bipartite?
A simple graph is bipartite if and only if it is possible to assign one of two different colours to each
vertex of the graph so that no two adjacent vertices are assigned the same colour.
8. What is a complete bipartite graph?
A complete bipartite graph Km,n is a graph that has its vertex set partitioned into two subsets of m and
n vertices, respectively with an edge between two vertices if and only if one vertex is in the first subset
and the other vertex is in the second subset. |
9. When are 2 graphs isomorphic?
The simple graphs G1 = (V1,E1) and G2 = (V2,E2) are isomorphic if there exists a one to- one and onto
function f from V1 to V2 with the property that a and b are adjacent in G1 if and only if f (a) and f (b)
are adjacent in G2, for all a and b in V1.
10. What are the conditions to be satisfied for 2 graphs to be isomorphic?
A property preserved by isomorphism of graphs is called a graph invariant. Two isomorphic graphs have
the
1. Same number of edges
2. Same number of vertices
3. The degrees of the vertices in isomorphic simple graphs must be the same
11. Define the terms path, circuit, simple path and simple circuit:Path: A path is a sequence of edges that begins at a vertex of a graph and travels from vertex to
vertex along edges of the graph. Path is also referred to as walk.
Circuit: A path is a circuit if it begins and ends at the same vertex
Simple Path: A path or circuit is simple if it does not contain the same edge more than once.
Simple Circuit: A circuit is a simple circuit if it does not contain the same edge more than once
19
2014-2015
12. Define strongly and weakly connected graph:A directed graph is strongly connected if there is a path from a to b and from b to a whenever a
and b are vertices in the graph.
A directed graph is weakly connected if there is a path between every two vertices in the
underlying undirected graph.
13. Define Euler circuit and Euler path in a graph:An Euler circuit in a graph G is a simple circuit containing every edge of G. An Euler path in G
is a simple path containing every edge of G.
14. Define graph colouring:A colouring of a simple graph is the assignment of a colour to each vertex of the graph so that no
two adjacent vertices are assigned the same colour.
15. What is chromatic number of a graph?
The chromatic number of a graph is the least number of colours needed for a colouring of that
graph.
16. State four colour theorem:The chromatic number of a planar graph is no greater than four.
17.What is a clique?
A clique is a subset of nodes such that each node is connected to all other nodes of the subset.
18. Define a tree:A tree is a connected undirected graph with no simple circuits.
19. What is a rooted tree and an m-ary tree?
A rooted tree is a tree in which one vertex has been designated as the root and every edge is
directed away from the root.
A rooted tree is called an m-ary tree if every internal vertex has no more than m children. The tree
is called a full m-ary tree if every internal vertex has exactly m children. An m-ary tree with m = 2
is called a binary tree.
20. Define a Spanning tree of a graph:Let G be a simple graph. A spanning tree of G is a sub-graph of G that is a tree containing every
vertex of G.
20
2014-2015
PART B
1.a)Describe the generic graph classification simple, directed etc. Present your description in the form a
table. No need for extra textual description.
b)What are isomorphic graphs? Explain with an example. What are some pre-conditions that need to be
met by isomorphic graphs show them with examples:c) Two fully connected graphs each with 10 nodes are given are they isomorphic justify:2. Describe the term clique with an example.
Describe an algorithm to find the maximum clique in any given graph
Input: graph G(V, E), size V is n; Output should be the largest clique and its size.
Compute the approximate complexity of your algorithm in terms of number of vertices:What is the maximum clique size of Kn and what happens to this clique size when one of the vertices is
removed?
21
2014-2015
Finding the shortest path between any two arbitrary nodes in the given graph.
Isomorphic graphs (given two arbitrary graphs show they are isomorphic or not)
Maximum clique
Maximum Independent Set
UNIT-V
PART-A
1. What is a String?
22
2.
2014-2015
i.e. L V*.
a. A programming language can be thought of as the set of all possible programs, where a
program is a valid string (a very long string).
b. Programs with syntax errors are not in the set.
A language can be finite or infinite.
c. Programming languages are infinite.
d. i.e. there are an infinite number of programs.
3. Define a Grammar: A grammar is a way to specify the set of all legal sentences of a language (i.e. to specify the set of
all legal programs of a programming language).
Grammars are defined recursively (i.e. some elements are defined in terms of themselves).
Recursive definitions are also called inductive definitions (i.e. they induce, rather than enumerate,
the set of strings).
4.When do we say that a function is computable?
A function is computable if there is a computer program in some programming language that finds the
values of this function. If a function is not computable we say it is uncomputable.
5. What are the 3 equivalent computational processes?
All three computational processes (recursion, the -calculus, and the Turing machine) can be
shown to be equivalentall three approaches define the same class of functions.
23
2014-2015
24
2014-2015
Consider the class of statements each of which asks whether a particular integer n is prime. This
is a decision problem because the answer to the question Is n prime? is either yes or no.
15. Define decidability:When there is an effective algorithm that decides whether instances of a decision problem are true, we say
that this problem is solvable or decidable or computable.
Example of solvable problem: Given a number N, finding if N is a prime or not.
If no effective algorithm exists for solving a problem, then we say the problem is unsolvable or
undecidable.
Example: Halting Problem
Formal Definition:- Let be an alphabet and let A *be a language. We say that A is decidable, if
there exists a Turing machine M, such that for every string w *, the following holds:
1. If w A, then the computation of the Turing machine M, on the input string w, terminates in the
accept state.
2. If w A, then the computation of the Turing machine M, on the input string w, terminates in the
reject state.
In Halting problem, string w represents another TM B with its input.
16.Distinguish between a decision problem and a function problem:St.Josephs College of Engineering
25
2014-2015
To solve a decision problem, an algorithm has to accept each instance of the problem as input,
and return Yes or No depending on whether the instance is a Yes-instance.
To solve a function problem, an algorithm has to accept each instance I of the problem as input,
and return the unique sol(I).
17. Define Computability:A function that can be computed by a Turing machine is called computable and a function that cannot be
computed by a Turing machine is called un-computable.
18. State Church-Turing Thesis:ChurchTuring thesis states that given any problem that can be solved with an effective algorithm, there
is a Turing machine that can solve this problem.
Informally, the converse of this thesis suggests, that if a problem cannot be solved with Turing machine
then there is no effective algorithm for it.
19. What are P and NP problems?
A decision problem is in P, the class of polynomial-time problems, if it can be solved by a
deterministic Turing machine in polynomial time in terms of the size of its input.
That is, decision problem is in P if there is a deterministic Turing machine T that solves the decision
problem and a polynomial p(n) such that for all integers n, T halts in a final state after no more than
p(n) transitions whenever the input to T is a string of length n.
A decision problem is in NP, the class of nondeterministic polynomial-time problems, if it can be
solved by a nondeterministic Turing machine in polynomial time in terms of the size of its input.
That is, a decision problem is in NP if there is a nondeterministic Turing machine T that solves the
problem in a polynomial time p(n) such that for all integers n, T halts for every choice of transitions
after no more than p(n) transitions whenever the input to T is a string of length n.
16. Explain computational complexity with examples:
Complexity, typically represents the upper bound of the computational time of the algorithm for
an input of size n
Upper bound is not same as worst case time. It is larger than or equal to worst case time
Some Examples:
26
2014-2015
Finding the smallest number in a given list n of unordered integers. This algorithm
execution
(approximated)
Finding if a number exists in an ordered list of n numbers. In this case, there are log n
comparisons that dominate the algorithm.
PART-B
1. Explain the following terms: Big O notation, P, NP, NP-hard, NP-complete, tractable and intractable
problems:2. Concisely list the binary strings recognized by the following FSM:
3. a)Write the regular expression to find remove the # appearing at the beginning a given string S.
Replace # by $.
b)Compare Mealy machine with Moore machine
4. Let G be the grammar with vocabulary V = {S, A, 0, 1}, set of terminals T = {0,1}, starting
symbol S, and productions P = {S 0A, S 1010, A 101}. What is L(G), the language of
this grammar?
5. Draw a FSM to model a vending machine that dispenses a Pepsi when button P is pressed and
Coke when button C is pressed. This machine can take both 5 Rs or 10 Rs coin. If 5 Rs coin is
inserted, there is no change returned. If 10 Rs coin is inserted, then a 5 Rs coin is dispensed along
with a Coke/Pepsi.
6. a)Problem, Algorithms, and Complexity. Discuss the relationship among the three with an
example.
b)Order the Big O notation complexities listed here in the order of their increasing complexities:
27
2014-2015
O(n2), O(n3), O(n), O(n log n), O(2n), O(nn), O(1), O(log n)
c) Describe the relationship between P and NP using Venn Diagram
7. Compute the complexity of Satisfiability algorithm that finds if a given propositional formula
with n variables is valid or not. Is this an NP-Complete problem?
8. Explain the relationship between TM and Church thesis
Describe the following aspects of Turing Machine: Operation, Components. List four Different
variations of TM.
9. Develop a Turing machine T that accepts Palindromes. Assume the following alphabet {a, b, B}.
The symbol B represents Blank character.
10. Build a Turing machine T that computes the function f (n1, n2) = n1 + n2. The pair (n1, n2) is
represented by a string of n1 + 1 1s followed by an asterisk followed by n2 + 1 1s. The machine T
should take this as input and produce as output a tape with n1 + n2 + 1 1s.
28