Vous êtes sur la page 1sur 41

MATHEMATICAL FOUNDATION OF COMPUTER SCIENCE

1. Syllabus
UNIT-I
Mathematical Logic: Statements and notations, Connectives, Well formed formulas, Truth Tables, tautology,
equivalence implication, Normal forms.
UNIT-II
Predicates: Predicative logic, Free & Bound variables, Rules of inference, Consistency, proof of contradiction,
Automatic Theorem Proving.
UNIT-III
Set Theory: Properties of binary Relations, equivalence, compatibility and partial ordering relations, Hassel diagram.
Functions: Inverse Function Comports of functions, recursive Functions, Lattice and its Properties, Pigeon hole
principles and its application.
UNIT-IV
Algebraic structures: Algebraic systems Examples and general properties, Semi groups and monads, groups sub
groups homomorphism, Isomorphism.
UNIT-V
Elementary Combinatory: Basis of counting, Combinations & Permutations, with repetitions, Constrained repetitions,
Binomial Coefficients, Binomial Multinomial theorems, the principles of Inclusion Exclusion.
UNIT-VI
Recurrence Relation: Generating Functions, Function of Sequences Calculating Coefficient of generating function,
Recurrence relations, Solving recurrence relation by substitution and Generating funds. Characteristics roots solution of
in homogeneous Recurrence Relation.
UNIT-VII
Graph Theory : Representation of Graph, DFS, BFS, Spanning Trees, planar Graphs
UNIT-VIII
Graph Theory and Applications, Basic Concepts Isomorphism and Sub graphs, Multi graphs and Euler circuits,
Hamiltonian graphs, Chromatic Numbers
2. TEXT BOOKS :
1. Discrete and Combinational Mathematics- An Applied Introduction-5th Edition Ralph. P.Grimaldi.Pearson
Education
2. Discrete Mathematical Structures with applications to computer science Trembly J.P. & Manohar .P, TMH
3.Discrete Mathematics and its Applications, Kenneth H. Rosen, Fifth Edition.TMH.

REFERENCES :
1. Discrete Mathematics with Applications, Thomas Koshy, Elsevier

2. Discrete Mathematical Structures, Bernand Kolman, Roberty C. Busby, Sharn Cutter Ross, Pearson Education/PHI.
3. Discrete Mathematical structures Theory and application-Malik & Sen
4. Discrete Mathematics for Computer science, Garry Haggard and others, Thomson.
5. Discrete Mathematics for Computer Scientists & Mathematicians, J.L. Mott, A. Kandel, T.P. Baker Prentice Hall.
6. Logic and Discrete Mathematics, Grass Man & Trembley, Person Education

Web resources:
http://www.utm.edu/departments/math/graph/
http://cr.yp.to/2005-261/bender2/GT.pdf
http://www.math.psu.edu/simpson/papers/philmath/
http://page.mi.fu-berlin.de/raut/logic3/announce.pdf
http://www.jcu.edu/math/vignettes/logic.htm
http://dogschool.tripod.com/
http://www.mathdb.org/notes_download/elementary/algebra/ae_A11.pdf
http://simomaths.wordpress.com/2012/02/05/power-series-and-generating-functions-i-basics/

3. Course Objectives &Outcomes


S.No Subject/lab Objectives
1
Students will obtain skills and logical perspectives in computer science

core curses the prepare them for subsequent courses inside and outside
computer science
2

The ability to evaluate logical arguments, and the ability to apply


mathematical methodologies to solving real world problem

Students will acquire a strong facility for developing, analyzing and


applying algorithms

Learn problem-solving techniques and become proficient and


confident in solving problems

Student will acquire design, and implement basic data structures such
as queues, binary trees, graphs

Student will acquire implement basic searching algorithms

S.No Subject/lab Outcomes


1
Understand the logical equations and solving equations
2
Student gets proficiency in basic algorithm extraction
3

Given a problem statement, be able to extract the given data as input,


formulate a clear goal or desired output, and layout a set of instructions
to go from input to output

Student have detailed knowledge about generating functions and its


applications

Student get an ability to understood the theorems and derivation


techniques

Student have detailed knowledge about the graph theory and able to
apply graph theory techniques to various fields in computer science

4. Macro lesson Plan (Term wise & Week wise)Note: Term I means 8 weeks covering 14 units of syllabus and Term II means 8 weeks covering 5-8 units of syllabus)
Period
01
02
03
04
05
06
07
08
Period
09
10
11
12
13
14
Period
15
16
17
18
19
20
21

Unit-1
Predicate
logic

Unit-2
Predicates

Unit-3
Set Theory

Term-I ( 01-07-2013 to 23-08-2013)


Topic to be covered
Statements and notations
Connectives, truth tables
Well formed formulas, Equivalence implication
Equivalence implication
Tautology
Tautology
Normal forms
Normal forms
Topic to be covered
Free &Bound variables, Rules of inference
Consistency
Consistency
Proof of Contradiction
Proof of Contradiction
Automatic theorem proving
Topic to be covered
Properties of binary relations, equivalences
Equivalences
Compatibility and partial ordering relations
partial ordering relations, Hasse Diagrams
partial ordering relations, Hasse Diagrams
Inverse functions,
recursive relations

22
23
24
Period Unit-4
Algebraic
25
structures
26
27
28
29
30
31
32
33
34
35
Period Unit-5
Elementary
36
Combinatorics
37
38
39
40
41
42
Period Unit-6
Recurrence
43
Relation
44
45
46
47
48
49
50
Period Unit-8
Graph Theory
51
and
52
applications
53
54
55
56
57
58
59
Period Unit-7
Graph Theory
60

Lattice and its properties


Theorems on Lattices
Pigeonhole principles and its applications
Topic to be covered
Algebric system examples and general properties
Semigroup,moniod
Group
Theorems on Group
Subgroup
Theorems on Subgroup
Homomorphisam
Isomorphisam
Applications
Applications
Applications
Term-II (26-8-2013 to Last)
Topic to be covered
Basis of counting, Combinations & Permutations
Combinations & Permutations with repetition
Binomial equations and its Coefficients
Binomial equations and its Coefficients
Binomial Multinomial theorems
Binomial Multinomial theorems
Principles of Inclusion-Exclusion
Topic to be covered
Generating Functions, Function of Sequences
Generating Functions, Function of Sequences
Calculating Coefficient of generating function
Recurrence relations
Solving recurrence relation by substitution
Solving recurrence relation by Generating funds
Characteristics roots solution of In homogeneous Recurrence
Relation
Characteristics roots solution of In homogeneous Recurrence
Relation
Topic to be covered
Graph Theory and Applications
Basic Concepts Isomorphism
Isomorphism
Sub graphs
Multi graphs
Euler circuits
Euler circuits and Hamiltonian graphs
Hamiltonian graphs
Chromatic Numbers
Topic to be covered
Representation of graph

61
62
63
64
65
66
67

and
applications

Representation of graph
DFS
BFS
Spanning tree
Minimal Spanning tree
Planner graph
Planner graph

5. Unit wise important Questions


Unit -1
1. Compute the truth table of the function

2. Define tautology, contradiction and contingency of formula.


3. Constuct the truth table for the following statement

4. Show that the following statements is a tautology.

5. construct the truth table for the following statement

6. Show that the following statements are logically equivalent without using truth table

7. Prove that the following equation is contradiction

8. Obtain PDNF and PCNF of the following formula

Unit -2
1. Using rules of inference prove the following
a. Xavier is a black cat
Xavier is not bad luck
Therefore not all black cats are bad luck
UNIVERSE=CAT
b. All cats are pretty

All pretty animals are nice


Therefore all cats are nice
Universe= animals
c. All fun cities have amusement parks
Some city in Goa in fun
Therefore some city in Goa has an amusement park
Universe = cities
2. Write the quantified statements for the following statements
F(x):X is a fruit
V(x):X is a vegetable
S(x,y):X is sweeter than y
Convert the following
1. Some vegetables are sweeter than all fruits
2. Every fruit is sweeter than all vegetables
3. Every fruit is sweeter than some vegetables
4. Only fruits are sweeter than vegetables
3. Prove the following statements are valid or not
a. I study well
If I study well, I will pass the exam
If I pass the exam,my father will buy a sports bike for me
Therefore my father will buy sports bike for me
b. Preety likes pets or birds
If Preety likes birds then her father will buy bird cages
If preety father buy bird cage then he will not buy chains
Therefore preety doesnot like pets
4. Check the following premises are consistent or not
r V s , (r V s)(~t ^ u),(~t ^ u)
5. Check the following premises are valid or not
Rita is baking a cake.

If Rita is baking a cake,then she is not practicing her flute.


If Rita is not practicing her flute,then her fateher will not buy a her a car.
Therefore Ritas father will not buy her a car.
6. Check the following premises are consistent or not
p r, rs, t V ~s, ~t V u, ~u, ~p
7. What is the valid conclusion for the following premises
pq , q(r ^ s), ~r V(~t V u),p ^ t
8. Prove the following

Unit -3
1. Simply the expression
2. Prove that the following set is a poset S={(a,b)/a divides b}
3. Prove the following set satisfies equivalent relation or not
S= {(a,b)/a+b is even,(a,b) Z}
4. Find the inverse of the following function F(x) = x/x+2
5. Prove that every chain is distributive lattice
6. Write the hasse diagram and relational matrices for the poset {a, b, c, d} relation is such
that SUBSET
7. Draw the hasse diagram for the poset (P(s),

) where S= {1,2,3,4}

8. Define the following


a. Lattice and its properties
Distributive lattice

b. total ordered set

c.Infimum & Suprimum d.

Unit -4
1.
2.
3.
4.

Prove that a group consisting of three elements is abelian


H is a subgroup of G iff for ever a,b G,suchthat a*b =a+b-ab
Prove that additional modulo 5 is a group
Define what is a Ring and give an example

5. Prove that identity in a group is unique


6. Prove that the union of two subgroup of a group is a subgroup iff one is contained
in the other
7. If G is the set of all matrices of the type

where ae.Prove that G is an

abelian group under matrix multiplication


8. Prove the Legranges theorem
Unit-5
1.
2.
3.
4.
5.

State and explain binomial theorem


Find the coefficient for x5y4z3,3x45y56z37t4
Find the 9th term in the expansion(5x+3y)13
What is Multinomial theorem state and give the formula for nth term
How many positive numbers,with non- repeated digits are there such that
10n9999
6. Find the number of positive integer solutions of X1+X2+X3+X4+X5<10
7. Using the Pascal identity prove

8. How many different 8-digits numbers can be formed by arranging the digits 1, 1,
1,1,1,2,3,3,3?
Unit-6
1. Define what is a generating function? Give an example
2. Solve the recurrence relations

3. solve the recurrence relation using generating function

4. Solve the recurrence relations

5. Write the generating function for

6. Find a particular solution for recurrence relation using the method of determinate
coefficients

7. Solve the recurrence relation using generating function of

8.Find the generating function for the series 1,0,1,1,0,-1,1,1,1,.


Unit -7
1.
2.
3.
4.
5.

Explain DFS with a graph.


Explain BFS with a graph
What is prims algorithm with an example.
Define spanning tree. What are its characteristics.
Derive all possible spanning trees for the graph

6. What is a planner graph check k4 is planner or not


7. How to find a minimal spanning tree with an example
8. Define the following
a.spanning tree
b.subgraph
c.Minimal spanning tree
d.backtracking
Unit-8
1. Define the following
a. Complete graph b. Regular graph
size

c. bipartite graph

d. order and

2. What is handshaking property? Explain with an example


3. What is a Hamiltonian graph? Give the differences between Hamiltonian and
Euler graph
4. What is ment by chromatic number find the chromatic number of K6
5. Check the following graphs are Hamiltonian or not? Write an algorithm to find it

6. Find the chromatic number for the following graph

7. Write the DFS and BFS for the above diagram


8. What is meant by isomorphism? What are the conditions to satisfy graphs are
isomorphic? Give an example
f6. Unit wise Objective Questions with answers written separately.

Unit-1
1. Which of the following is FALSE about the conditional statement if P then Q?
a. p is necessary but not sufficient for Q
C.P is necessary and sufficient for Q

b. Q is necessary and sufficient for P


d. None(c)

2. Mathematical logic is used in computer science to verify the correctness of ?


a. Testing

b.Programming

c.Requirements

3. The converse of pq is
a. ~ pq

b. ~ p~q

c. ~qp

d. qp (d)

d.None (b)

4. P V T is
a. P

b. T

c. both d. None (b)

5. Which of the following is min term


a. pq b.p V q

c. P ^ Q

d. qp(c)

6. Which of the following is tautology

7. The contrapositive of pq is
a. pq b. qp c. ~q~p d.None(c)
8. The inverse of pq is
a. pq

b. qp

c. ~p~q d. None (c)

9. A declarative sentence that is either true or false but not both is called
a. Preposition b. Statement

c. Logic

d. none (a or b)

10. The propositions that do not have any connective s are called
A. logic

b. proposition

c. Atomic statement

d. None (c)

11. The disjunction of two statements P and Q is ____


12. Write the negation of the statement 2 is even and -3 is negagtive___
13. What is the converse of the statement If I have time and I am not too tired, then I will
go to the store__________
14. What is the PDNF of (pq) V r ________
15. p V q, ~p V q, p V ~q, ~p V ~q are_______
16. If the proposition pq is true then P V (pq) is ____
17. What is the logical equivalence of ~p V q _____
18. Symblise the equation Swati likes to eat banana and carrot every day ____
19. P V F is logically equivalent to ___
20. P V (PVP V(PVP V(PVP V(PVP V(P..)))) is equivalent to _____
Unit -2
1. What is the universal Quantifier?

a. For all
b. for some c.There exist d. not all (a)
2. What is the existential quantifier?
a. For all
b. for some c. There exist d. not all (b or c)
3. If p is true and pq is true then
a. Q is true b. Q is false c.Q is neither true nor false d.None

4.
5.
6. If ~ p is true and pq then
a. P is false b. Q is false c.Q is true d. P is true
7. Which conclusion logically follows from the premises: I will become a
millionair.IF I join JNTU the I will get best education,If I get best education,then I will
get job in USA .If I get hob in USA then I will become a millionaire.I joined JNTU
a. I didnt study well b. I will not get job in USA C. I will become a millionair d.None
(C)

8.
9. Convert the following statements in notations

A.

b. P(X) c. Q(X) d. P(X) Q(X)

10. If P is true and PQ is true the that law is called


a. Modus tollen b. Modus pones
11.

C.Rule of syllogiam d.Rule of association(b)


= _____

12. Let Q(x,y,z) be the statement X +Y=3Z.What are the truth values of the
statements______

13. p(x): x is very hot ,q(x):x is very cold,r(x,y): the temperature of x is more than Y
check the validity______________
14.
15.
16.
17.
18.

__________
_________
______________
_______________
____________

19. Let p(x),q(x) denote the following open statements


if the
universe consisits of all integers,what are the truth values of the above statement_____
20. Rule of Syllogism is _______
Unit-3
1.

2.
3.

4:
5
6

9.

10

11.Anti symmetric means --------------12.{z,<} is a -------------set


13.In hasse diagram------------------- will be eliminated.
14.In hasse diagram------------reduction will be there.
15.Digraphs are used to represent-------------set
16.Reflexive means ------------.
17.lattice must have --------&-------------.
18.Distributive lattice is a ---------------.
19.Every lattice is a ______ set
20.Total ordered set is __________
Unit -4
1.{0,1,2,3,4} is a -----------under addition modulo 5.
a.monid b.semi group c.group d. none
2.semi group with identity element is ------------a.semigroup b.group c.monid.d. none
3.
4.
5.

6.

7.

8.

9.
1
10. Every sub group is a ------------a. Subset b. semigroup c.monid d.group
11.(I,*)is _______
12.(z,+) is _________
13.Hemomorphisam means______
14. O(H)/O(G)=______
15. if for every a,b Z then a*b=a+b-ab then G is________
16.If G satisfies group under * and semigroup under + then ___________
17. In a group identity element is ____
18.the Identity element of addition modulo 6 is ____
19.The inverse of the element 4 under additional modulo 5 is__
20.If in a group every element has its own inverse then it becomes____
Unit-5

1.

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.what is the coefficient of X5Y6 ______


12. what is the coefficient of 9th term in the expansion of (2X+4Y)13_____
13. What is the coefficient of y6 in the expansion of (X+Y)23______
14.what is the nth term of the expansion of Binomial theorem_______
15.what is a pigeon hole theorem___
16. If you draw six apples from a bag of ten apples and five oranges the probability of
getting apples only is____
17.In a password there is one capital letter and five small letters and one special character
(@#%$)and one number the possibilities of password is______
18.How many three letters word can be formed from ELEPHENT______

19.How many four letters word can be formed from SAXAPHONE without repeting
any letter is ____
20. npr =____________
Unit -6
1.

2.

3.
..

4.

5.

6. 1,-1,1,-1.. are the coefficients of generating function


a.sinx b.x c.1/1-x d.1/1+x
7.

8.

9.1,1,1,1,1,.. are the coefficients of generating function


a.sinx b.x c.1/1-x d.1/1+x
10.1,1/2,1/9,1/16.. are the coefficients of generating function
a.sinx b.x c.1/1-x d.1/1+x
11.The expansion of( 1+2x)-1 _______

12. The expansion of( 1+sinx)-1 _______


13. The expansion of( 1-2x)-1 _______
14. The expansion of( 1+x2)-1 _______
15. The expansion of( 1+x2+x)-1 _______
16.The generating function of
17. The generating function of
18. The generating function of

_______
_______
_______

19.The first order recurrence relation is__________


20.In nonhomogenous equation f(x)=___

Unit -7
1.

2. Backtracking algorithm involves in __


a. DFS b.BFS c. Kruskals d.Prism
3. In tree structure which is not there
a. Loops
b. Childs
c.Parents
d.leafs
4. In a graph if there exist a intersection points otherthan vertex is
a. Planner
b. Non Planner
c.Both
d.None
5. the graph is

a.Planner b. Non planner c.None


6. the chromatic number of the below graph is
a.2

b. 3 c.4 d.5

7. K4 is
a. Planner

b. Regular graph

c.Complete graph

d.None

8. The shortest path algorithm is resembles with


a. Minimal spanning tree b. DFS c. BFS d.None
9. Which is not algorithm for minimal spanning tree
a. Prism

b. Kruskals

c. Gingerberg d. None

10. The chromatic number of the below graph is


a.2 b.3 c.4 d.5

Unit-8
1.In a graph order means ____________.
2.In a graph handshaking property means ________
3.In a graph if all the vertices are having same degree than that graph
is______________.
4. Hamiltonian path existed in a graph means that graph is ________
5.If in walk we reached to initial vertex than it is ________
6.Gingerberg statement is __________
7.In bipartiate graph each vertices in one vertex set have _________
8.In a directed graph in degree is represented with _________
9.If in a graph a vertex does not have any relation with others than that vertex is _______
10.If V=2E then ________

7. Question bank consisting of 12 questions for assignment-I (4 units * 3


Question=12(total)
1. Prove the following argument is valid: p q, r q, r p.

2. De Morgans Laws for Logic. The following propositions are logically equivalent:

3. Consider the following statements: I take the bus or I walk. If I walk I get tired. I do not get tired.
Therefore I take the bus. We can formalize this by calling B = I take the bus,
W = I walk and T = I get tired. The premises are
, and T and the conclusion is B. The
argument can be described in
the following

4. Consider P.Q,R is premises show the following logical equivalence

5. Consider the following arguments


1. Rita is baking a cake
2. If Rita is baking a cake then she will not practice flute
3. If Rita is not practicing flute then her father will not buy a car
4. Therefore Ritas father will not buy her car
6.

7. Given A = {1, 2, 3, 4} and B = {x, y, z}. Let R be the following relation from A to B:
R = {(1, y), (1, z), (3, y), (4, x), (4, z)}
(a) Determine the matrix of the relation.
(b) Find the inverse relation R1 of R.
(c) Determine the domain and range of R.
8. . Consider the relation R = {(1, 3), (1, 4), (3, 2), (3, 3), (3, 4)} on A = {1, 2, 3, 4}.
(a) Find the matrix MR of R.
(d) Draw the directed graph of R.
(b) Find the domain and range of R.
(e) Find the composition relation RR.
(c) Find R1.

9 Assume that we choose three different digits from 1 to 9 and write all permutations of those digits. Prove
that among the 3-digit numbers written that way there are two whose difference is a multiple of 500
10. Find the number of mathematics students at a college taking at least one of the languages
French, German, and Russian, given the following data:
65 study French, 20 study French and German,
45 studies German, 25 study French and Russian, 8 study all three languages.
42 study Russian, 15 studies German and Russian

11. State and prove legranges theorem

12. If a H is asubgroup of G iff a,b E G for every ab=(ab)-1


Note: select three important questions from each of the first four units of syllabus
preferably not covered in unit wise important questions.
8. Question bank consisting of 12 questions for assignment-II (4*3=12)
1. Draw a Hasse diagram for Let A = {1, 2, 3, 4, 6, 8, 9, 12, 18, 24} be ordered by the
relation x divides y.
2. Three cards are chosen one after the other from a 52-card deck. Find the number m of
ways this can be done: (a) with replacement; (b) without replacement

3.

4. Find the number m of seven-letter words that can be formed using the letters of the word
BENZENE.

5.
6.

. Solve the following third-order homogeneous recurrence relation


an= 11an1 39an2 + 45an3

7. . Find a minimal spanning tree of the weighted graph Q .Note that Q has six
Vertices, so a minimal spanning tree will have five edges.

8. If G is the graph, the edges {a,b},{b,c},{c,f},{f,e},{e,d},{d,g},{g,h},{h,i} prove that it yields Hamilton


path for G.But does G have a Hamilton cycle?

9.Prove that
10. State and prove gingerberg theorem
11.State and Prove Handshaking property
12.Write the differences between Eular and Hamiltonian graphs

Note: select three important questions from each of the last four units of syllabus
preferably not covered in unit wise important questions.
9. Question bank consisting of 12 questions (4*3=12) for Mid-I
1. Show that the following statements are logically equivalent without using truth table

2. Prove that the following equation is contradiction

3. Obtain PDNF and PCNF of the following formula

4. Prove the following argument is valid: p q, r q, r p.


5. If p implies q and q implies r, then p implies r
6. Consider the following arguments
1. Rita is baking a cake
2. If Rita is baking a cake then she will not practice flute
3. If Rita is not practicing flute then her father will not buy a car
4. Therefore Ritas father will not buy her car
7. Consider the relation R = {(1, 3), (1, 4), (3, 2), (3, 3), (3, 4)} on A = {1, 2, 3, 4}.
(a) Find the matrix MR of R.
(d) Draw the directed graph of R.
8. Find the number of mathematics students at a college taking at least one of the languages

French, German, and Russian, given the following data:


65 study French, 20 study French and German,
45 studies German, 25 study French and Russian, 8 study all three languages.
42 study Russian, 15 studies German and Russian
9. Let B = {a, b, c, d, e}. Defines a partial order on B in the natural way. That is, d
b, d a, e c and so on Write a Hasse Diagram
10. Let C = {1, 2, 3, 4} be ordered as in Fig. 14-17(c). Let L(C) denote the collection of
all nonempties linearly ordered subsets of C ordered by set inclusion. Draw a diagram
of L(C).
11. If in a group G if a2 = e for all a is in G ,then prove that G is abelian group

12. The set of S of all ordered pairs (a,b) of real numbers for which a0 with respect to
the operation * denoted by (a,b)*(c,d)=(ac,bc+d) is a group find identiy element and
inverse
13. Prove that (p(qr))((pq)(pr)) is a tautology
14. Find the disjunctive normal form p(( pq)

Note: select three important questions from each of the first four units of syllabus
preferably not covered in unit wise important questions & assignment-I.
10. Question bank consisting of 12 questions (4*3=12) for Mid-II
1.
2.
3.
4.

State and explain binomial theorem


Find the coefficient for x5y4z3,3x45y56z37t4
Find the 9th term in the expansion(5x+3y)13
Solve the recurrence relations

5. solve the recurrence relation using generating function

6. Solve the recurrence relations

7. What is a planner graph check k4 is planner or not


8. How to find a minimal spanning tree with an example
9. Define the following
a.spanning tree
b.subgraph
c.Minimal spanning tree
d.backtracking

10. What is ment by chromatic number find the chromatic number of K6


11. Check the following graphs are Hamiltonian or not? Write an algorithm to find it

12. Find the chromatic number for the following graph

13. Write the DFS and BFS for the above diagram
Note: select three important questions from each of the last four units of syllabus
preferably not covered in unit wise important questions & assignment-II.
11. Lab syllabus
12. Lab objectives & outcomes
13. Lab schedule
Period
Week1
Week2
.

Experiment
Batch-1
Batch-II
Batch-1
Batch-II
Batch-1
Batch-II

Week - specific
01-07-2013 to
06-07-2013
08-07-2013 to
13-07-2013
.

14. Lab experiments in the form algorithms (pseudo code).


(Also Include experiments beyond the prescribed curriculum possibly extend the
existing lab experiments and justify how this will help)
16. Three sets of Pre-final Question papers
Set-1
1 a.Define the following i) Tautology ii) Contrapositive iii) Well defined formula iv)Modustollens
(4x2=8)

b. what is the compound statement that is true when exactly two of the three statements p,q and r
are true
(3M)
c. Obtain PDNF of p ((p q) ^ ~(~q v ~p)
(4M)
2 a. write the following prepositions into statements
P: you have the flee
Q: You miss the final examinations
R: you pass the course
i)

P q ii) (P ^ Q) v (~ q ^ r) iii) p ~r iv) p v q v r

(4x2=8)

b. i) construct truth table for the following preposition (p ^ q) v (q ^ r) v (p^ ~r)


(4M)
ii) Check the validity of the premises ( P q ) r , p ^ s, q ^ t, r
(3M)
3 a. show that (A U B) X C = (A X C) U (B X C)
(7M)
b X= { 2,3,6,12,24,36} if a relation defined on X as x<y and x divides y . Then find what type
of relation it is and write hasse diagram, Relational matrix
(8M)
4 a. The set of S of all ordered pairs (a ,b) of real numbers for which a 0 with respect to the
operation * denoted by (a, b)*(c ,d)= (ac, bc+d) is a group
(7M)
Find i) the identity ii) inverse of each element of g

b. prove that H is a subgroup go G if and only if for all a,bEH, we have abEH and a-1
(8M)
5 a. A palindrome is a word that reads the same forward or back word.How many nine letter
palindromes are possible (in English alphabets)
(3M)
b. Find the distinct triples (X1,X2,X3) of non negative integers satisfying x1+x2+x3<15
(4M)
c. Find the number of integers <500 and divisible by 7 or 9
(8M)
6. a. Solve the recurrence relation Un +5Un-1+6Un-2 = 3n2-2n+1
(8M)
b. find the generating function of sequence 4,5,7,11,19,35,
(7M)
7 What is a spanning subgraph? Find spanning tree from the graph using DFS & BFS
(8+7)

8 a Find the Fig-2 graphs are isomorphic or not

Fig-2

B Find what type of graphs Fig-2 are (Hamiltonian/eular/both) and check planarity
(7+8)
Set-2

1 a Prove the following

2 a Prove the following

b obtain pcnf and pdnf of p v Q


3
And also find the type of relation it is
3b

4 a State and prove lagranges theorem


b. H is a subgroup of G if and only if , for all a,b E H ,we have ab E H and a-1 E H

5 a find the coeff of x3y6 in (4x+5y) 9, x4y3z4 in (x+y+z)14

6a
6 b solve the following recurrence relations using generating function
Un +5Un-1+6Un-2 = 3n2-2n+1

7 a Find the minimumum spanning tree using kruskuals algorithm

7 b find the spanning tree from Fig a (without considering weights) using DFS
8 a Define the following give necessary examples
i)
ii)
iii)
iv)
v)

Simple graph
Bi partiate graph
Complete graph
Spanning sub graph
In degree and out degree

8 b Check the following graphs are planner or not, if yes find the chromatic number

.
Set-3
1.How to determine whether a graph contains Hamiltonian cycle or not using Grinberg
theorem
2.

3.

4.

5.

6.

7. Obtain the spanning tree by using DFS and BFS vertex set {a, b, c, d, e, f, g, h, i}

8. State and Prove Binomial theorem with an example

17. Any other important material, to include in student hand book.


Contents Beyond the syllabus

COMPLEXITY OF ALGORITHMS
The analysis of algorithms is a major task in computer science. In order to compare
algorithms, we must have some criteria to measure the efficiency of our algorithms. This
section discusses this important topic.
Suppose M is an algorithm, and suppose n is the size of the input data. The time and
space used by the algorithm are the two main measures for the efficiency of M. The time
is measured by counting the number of key operations; for example:
(a) In sorting and searching, one counts the number of comparisons.
(b) In arithmetic, one counts multiplications and neglects additions.
Key operations are so defined when the time for the other operations is much less than or
at most proportional to the time for the key operations. The space is measured by counting
the maximum of memory needed by the algorithm.
The complexity of an algorithm M is the function f (n) which gives the running time
and/or storage space requirement of the algorithm in terms of the size n of the input data.
Frequently, the storage space required by an algorithm is simply a multiple of the data
size. Accordingly, unless otherwise stated or implied, the term complexity shall refer to
the running time of the algorithm.
The complexity function f (n), which we assume gives the running time of an
algorithm, usually depends not only on the size n of the input data but also on the
particular data. For example, suppose we want to search through an English short story
TEXT for the first occurrence of a given 3-letter word W. Clearly, if W is the 3-letter word
the, then W likely occurs near the beginning of TEXT, so f (n) will be small. On the
other hand, if W is the 3-letter word zoo, then W may not appear in TEXT at all, so f (n)
will be large.
The above discussion leads us to the question of finding the complexity function f (n)
for certain cases. The two cases one usually investigates in complexity theory are as
follows:
(1) Worst case: The maximum value of f (n) for any possible input.
(2) Average case: The expected value of f (n).
The analysis of the average case assumes a certain probabilistic distribution for the
input data; one possible assumption might be that the possible permutations of a data set
are equally likely. The average case also uses the following concept in probability theory.
Suppose the numbers n1, n2, . . . , nk occur with respective probabilities p1, p2, . . . , pk .
Then the expectation or average value E is given by
E = n1p1 + n2p2 + + nk pk
These ideas are illustrated below.

Linear Search
Suppose a linear array DATA contains n elements, and suppose a specific ITEM of

information is given. We want either to find the location LOC of ITEM in the array
DATA, or to send some message, such as LOC = 0, to indicate that ITEM does not appear
in DATA. The linear search algorithm solves this problem by comparing ITEM, one by
one, with each element in DATA. That is, we compare ITEM with DATA[1], then
DATA[2], and so on, until we find LOC such that ITEM = DATA[LOC].
The complexity of the search algorithm is given by the number C of comparisons
between ITEM and DATA[K]. We seek C(n) for the worst case and the average case.
(1) Worst Case: Clearly the worst case occurs when ITEM is the last element in the
array DATA or is not there at all. In either situation, we have
C(n) = n
Accordingly, C(n) = n is the worst-case complexity of the linear search algorithm.
(2) Average Case: Here we assume that ITEM does appear in DATA, and that it is
equally likely to occur at any position in the array. Accordingly, the number of
comparisons can be any of the numbers 1, 2, 3, . . . , n, and each number occurs
with probability p = 1/n. Then
1
C(n) = 1

1
+2

1
++n
n

1
= (1 + 2 + + n) n
n(n +
n+
1)
1
1
=

This agrees with our intuitive feeling that the average number of comparisons
needed to find the location of ITEM is approximately equal to half the number of
elements in the DATA list.
Remark: The complexity of the average case of an algorithm is usually much more
complicated to analyze than that of the worst case. Moreover, the probabilistic distribution
that one assumes for the average case may not actually apply to real situations.
Accordingly, unless otherwise stated or implied, the complexity of an algorithm shall
mean the function which gives the running time of the worst case in terms of the input
size. This is not too strong an assumption, since the complexity of the average case for
many algorithms is proportional to the worst case

Rate of Growth; Big O Notation


Suppose M is an algorithm, and suppose n is the size of the input data. Clearly the
complexity f (n) of M increases as n increases. It is usually the rate of increase of f (n) that
we want to examine. This is usually done by comparing f (n) with some standard function,
such as
log n,

n,

n log n,

n2 ,

n3,

2n

The rates of growth for these standard functions are indicated in Fig. 3-7, which gives
their approximate values for certain values of n. Observe that the functions are listed in
the order of their rates of growth: the logarithmic function log2 n grows most slowly, the
exponential function 2n grows most rapidly, and the polynomial functions nc grow
according to the exponent c.

The way we compare our complexity function f (n) with one of the standard functions
is to use the functional big O notation which we formally define below.
Definition 3.4: Let f (x) and g(x) be arbitrary functions defined on R or a subset of R. We
say f (x) is of order g(x), written
f (x) = O(g(x))
if there exists a real number k and a positive constant C such that, for all x > k, we have
|f (x)| C|g(x)|
In other words, f (x) = 0(g(x)) if a constant multiple of |g(x)| exceeds |f (x)| for all x
greater than some real number k.
We also write:
f (x) = h(x) + O(g(x)) when f (x) h(x) = O(g(x))
(The above is called the big O notation since f (x) = o(g(x)) has an entirely different
meaning.)
Consider
now a polynomial P (x) of degree m. We show in Problem 3.24 that P (x) =
O(xm).
Thus, for example,
7x2 9x + 4 = O(x2)

and

8x3 576x2 + 832x 248 = O(x3)

Complexity of Well-known Algorithms


Assuming f(n) and g(n) are functions defined on the positive integers, then
f (n) = O(g(n))
means that f (n) is bounded by a constant multiple of g(n) for almost all n.
To indicate the convenience of this notation, we give the complexity of certain wellknown searching and sorting algorithms in computer science:

(a)
(b)

Linear search: O(n)


Binary search:
O(logn n)

(c)
(d)

Bubble sort: O(n2)


Merge-sort: O(n
log n)

INTRODUCTION, DATA STRUCTURES


__________________________________________________________________
__
Graphs, directed graphs, trees and binary trees appear in many areas of
mathematics and computer science. This and the next two chapters will cover these topics.
However, in order to understand how these objects may be stored in memory and to
understand algorithms on them, we need to know a little about certain data structures. We
assume the reader does understand linear and two-dimensional arrays; hence we will only
discuss linked lists and pointers, and stacks and queues below

Linked Lists and Pointers


Linked lists and pointers will be introduced by means of an example. Suppose a
brokerage firm maintains a file in which each record contains a customers name and
salesman; say the file contains the following data:
Custome
Brow
r
Adams n

Evan Farme
Clark Drew s
r
Geller Hiller Infeld

Salesma
n
Smith Ray

Ray

Jones Smith Jones

Ray

Smit
h

Ray

There are two basic operations that one would want to perform on the data:
Operation A: Given the name of a customer, find his salesman.
Operation B: Given the name of a salesman, find the list of his customers.
We discuss a number of ways the data may be stored in the computer, and the ease with
which one can perform the operations A and B on the data.
Clearly, the file could be stored in the computer by an array with two rows (or
columns) of nine names. Since the customers are listed alphabetically, one could easily
perform operation A. However, in order to perform operation B one must search through
the entire array.
One can easily store the data in memory using a two-dimensional array where, say, the
rows correspond to an alphabetical listing of the customers and the columns correspond to
an alphabetical listing of the salesmen, and where there is a 1 in the matrix indicating the
salesman of a customer and there are 0s elsewhere. The main drawback of such a
representation is that there may be a waste of a lot of memory because many 0s may be
in the matrix. For example, if a firm has 1000 customers and 20 salesmen, one would need
20 000 memory locations for the data, but only 1000 of them would be useful.

We discuss below a way of storing the data in memory which uses linked lists and
pointers. By a linked list, we mean a linear collection of data elements, called nodes,
where the linear order is given by means of a field of pointers. Figure 8-1 is a schematic
diagram of a linked list with six nodes. That is, each node is divided into two parts: the
first part contains the information of the element (e.g., NAME, ADDRESS,), and the
second part, called the link field or next pointer field, contains the address of the next node
in the list. This pointer field is indicated by an arrow drawn from one node to the next
node in the list. There is also a variable pointer, called START in Fig. 8-1, which gives
the address of the first node in the list. Furthermore, the pointer field of the last node
contains an invalid address, called a null pointer, which indicates the end of the list

The above fig is linked list with 6 nodes


One main way of storing the original data pictured in Fig. 8-2, uses linked lists.
Observe that there are separate (sorted alphabetically) arrays for the customers and the
salesmen. Also, there is a pointer array SLSM parallel to CUSTOMER which gives the
location of the salesman of a customer, hence operation A can be performed very easily
and quickly. Furthermore, the list of customers of each salesman is a linked list as
discussed above. Specifically, there is a pointer array START parallel to SALESMAN
which points to the first customer of a salesman, and there is an array NEXT which points
to the location of the next customer in the salesmans list (or contains a 0 to indicate the
end of the list). This process is indicated by the arrows in Fig. 8-2 for the salesman Ray.

Operation B can now be performed easily and quickly; that is, one does not need to search
through the list of all customers in order to obtain the list of customers of a given
salesman. Figure 8-3 gives such an algorithm (which is written in pseudo code).
Stacks, Queues, and Priority Queues
There are data structures other than arrays and linked lists which will occur in our
graph algorithms. These structures, stacks, queues, and priority queues, are briefly
described below.
(a) Stack: A stack, also called a last-in first-out (LIFO) system, is a linear list in which
insertions and deletions can take place only at one end, called the top of the list.
This structure is similar in its operation to a stack of dishes on a spring system, as
pictured in Fig. 8-4(a). Note that new dishes are inserted only at the top of the stack
and dishes can be deleted only from the top of the stack.
Algorithm: The name of a salesman is read and the list of his customers is printed
Step 1 : Read XXX
Step2: Find K such that SALESMAN[K] = XXX [use binary search]
Step3 : Set PTR : = START[K]. [Initializes pointer PTR]
Step4: Repeat while PTR NULL
a. Print CUSTMER [PTR]
b. Set PTR:= NEXT[PTR] [Update PTR]
[END of loop]
Step 5: Exit

(b) Queue: A queue, also called a first-in first-out (FIFO) system, is a linear list in which
deletions can only take place at one end of the list, the front of the list, and
insertions can only take place at the other end of the list, the rear of the list. The
structure operates in much the same way as a line of people waiting at a bus stop, as
pictured in Fig. 8-4(b). That is, the first person in line is the first person to board the
bus, and a new person goes to the end of the line.
(c) Priovity queue: Let S be a set of elements where new elements may be periodically
inserted, but where the current largest element (element with the highest priority) is
always deleted. Then S is called a priority queue. The rules women and children
first and age before beauty are examples of priority queues. Stacks and ordinary
queues are special kinds of priority queues. Specifically, the element with the highest
priority in a stack is the last element inserted, but the element with the highest priority
in a queue is the first element inserted.

DIVIDE-AND-CONQUER ALGORITHMS
__________________________________________________________________
__
The divide and conquer strategy solves a problem by:
(b)Breaking into sub problems that are themselves smaller instances of the same
type of problem.
(c) Recursively solving these sub problems.
(d)Appropriately combining their answers.
Two types of sorting algorithms which are based on this divide and conquer
algorithm:
1. Quick sort: Quick sort also uses few comparisons (somewhat more than the other
two). Like heap sort it can sort "in place" by moving data in an array.
2. Merge sort: Merge sort is good for data that's too big to have in memory at once,
because its pattern of storage access is very regular. It also uses even fewer
comparisons than heap sort, and is especially suited for data stored as linked lists.

Table for the running time of the algorithms:


In this table, n is the number of records to be sorted and k is the average length of the
keys. The columns "Best", "Average", and "Worst" give the time complexity in each
case; estimates that do not use k assume k to be constant. "Memory" denotes the
amount of auxiliary storage needed beyond that used by the list itself.
Name
Heap
sort
Merge
sort
Quick
sort

Best
O(nlogn)

Average
O(nlogn)

Worst
O(nlogn)

Memory
O(1)

Stable
No

Method
Selection

O(nlogn)

O(nlogn)

O(nlogn)

O(n)

Yes

Merging

O(nlogn)

O(nlogn)

O(n2)

O(logn)

No

Partitioning

Here we are discussing about the two algorithms quick sort and merge sort. We will also
discuss about their complexity and running time of algorithms.
Quick sort
Quick sort is one of the fastest and simplest sorting algorithms, which uses partitioning
as its main idea. It works recursively by a divide-and-conquer strategy.
Example: Pivot about 10.
17 12 6 19 23 8 5 10 - before
6 8 5 10 23 19 12 17 after
Partitioning places all the elements less than the pivot in the left part of the array, and
all elements greater than the pivot in the right part of the array. The pivot fits in the slot
between them.
Example: pivot about 10
| 17 12 6 19 23 8 5 | 10
| 5 12 6 19 23 8 | 17
5 | 12 6 19 23 8 | 17
5 | 8 6 19 23 | 12 17
5 8 | 6 19 23 | 12 17
5 8 6 | 19 23 | 12 17

5 8 6 | 23 | 19 12 17
5 8 6 ||23 19 12 17
5 8 6 10 19 12 17 23
Note that the pivot element ends up in the correct place in the total order!
In simple pseudo code, the algorithm might be expressed as:

Quick sort (q)


Var list less, pivotList, greater if
length (q) 1
Return q
Select a pivot value pivot from q
For each x in q except the pivot element if x <
pivot then add x to less
If x pivot then add x to greater add
pivot to pivot List
Return concatenate (quick sort(less), pivot List, quick sort (greater))

Complexity of Quick sort


Best case:
Set up a recurrence relation for T (n), the time needed to sort a list of size n. Because a
single quick sort call involves O (n) work plus two recursive calls on lists of size n/2 in
the best case, the relation would be:
T (n) = O (n) + 2T (n/2)
The master theorem tells us that T (n) = (n log n).
Average case:
The average number of comparisons over all permutations of the input sequence can
be estimated accurately by solving the recurrence relation:

Here, n - 1 is the number of comparisons the partition uses. Since the pivot is equally
likely to fall anywhere in the sorted list order, the sum is averaging over all possible
splits.
Worst case:
In the worst case, however, the two sub lists have size 1 and n- 1, and the call tree
becomes a linear chain of n nested calls. The ith call does O (n-i) work, and
\sum_{i=0}^n (n-i) = O (n^2). The recurrence relation is:
T (n) = O (n) + T (1) + T (n - 1) = O (n) + T (n - 1)
This is the same relation as for insertion sort and selection sort, and it solves to T (n)
= (n2).

Merge Sort
Merge Sort is an O (nlogn) sorting algorithm. It is easy to implement merge sort such
that it is stable meaning it preserves the input order of equal elements in the sorted
output. It is a comparison sort.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13
A [31 23 01 17 19 28 09 03 13 15 22 08 29]
1 : 13
1:7

8 : 13

1:4
1:2

3:4

31 23

01 17

23 31

01 17
01 17 23 31

5:7
5:6

8 : 10

7:7

19 28
19 28
09 19 28

8:9
09
09

11 : 13

10 : 10

03 13
03 13

11 : 12

15
15

03 13 15

01 09 17 19 23 28 31
01 03 08 09 13 15 17 19 22 23 29 31

13 : 13

22 08

29

08 22

29

08 22 29
03 08 13 15 22 29

Merge sort pseudo code


Algorithm merge sort (A, left, right)
Input: An array A of numbers, the bounds left and Right for the
elements to be sorted
Output: A [leftright] is sorted
If (left<right) {/*we have at least two elements to sort*/ mid<- [(left
+right)/2]
Merge sort (A, left, mid) /*now A
[left.mid]
Is sorted*/ merge sort (A, mid+1,
right)
/*now A [mid+1.right] is sorted */ Merge (A,
left, mid, right)
}

Complexity of Merge Sort


Best case:
If the running time of merge sort for a list of length n is T(n), then the recurrence T(n) =
2T(n/2) + n follows from the definition of the algorithm (apply the algorithm to two lists of half
the size of the original list, and add the n steps taken to merge the resulting two lists)
Worst and Average case:
In sorting n items, merge sort has an average and worst-case performance of O (n log n).The
worst case,
Merge sort does exactly (n log n - 2log n + 1) comparisons, which is between
(n log n - n + 1) and (n log n - 0.9139n + 1) [logs are base 2].
Merge sort's worst case is found simultaneously with quick sorts best case. In terms of
moves, merge sort's worst case complexity is O(n log n)

Konigsberg problem
The eighteenth- century East Prussian town of Konigsber included two islands and seven
bridges as shown in fig.
The Question is:
Beginning anywhere and ending anywhere, can a person walk through town
crossing all seven bridges but not crossing any bridge twice?
L.Euler solve this question as follows

Answer
The above fig can be illustrated as follows

By considering islands are vertices and bridges are edges and construct one graph. Since degree
of A,D,B is 3 and C is 5 .the degrees of vertices are not equal and not even. So by observing
above graph it is impossible to cover all the edges without repetition.So it is not an Euler graph
It is IMPOSSIBLE to travel all the bridges without repetation

Vous aimerez peut-être aussi