8/3/2019 SRM (2011) of I Sem
1/112
STUDENTS REFERENCE MANUAL
M.C.A. SEMESTER I
Jul-Dec (2011)
MASTER OF COMPUTER APPLICATION
(NBA Accredited)
ORIENTAL COLLEGE OF MANAGEMENT
BHOPAL
(Affiliated to Rajiv Gandhi Proudyogiki Vishwavidyalaya, Bhopal (M.P.)
8/3/2019 SRM (2011) of I Sem
2/112
CONTENTS
01. Code of Conduct for Student of Ocm
02. Academic Calendar for Semester I, 2011
03. Pattern of University Question Paper
04. Course of Study and Scheme of Examination
05. Academic Detail of Course MCA 101: Information Technology
(i) Course Contents
(ii) Lecture Plan with references
(iii) Unit wise blow up
(iv) Previous Univ. Exam Paper
(v) Model paper
(vi) List of Books
06. Academic Detail of Course MCA 102: Mathematical Foundation of Computer Science
(i) Course Contents
(ii) Lecture Plan with references
(iii) Unit wise blow up
(iv) Previous Univ. Exam Paper
(v) Model paper
(vi) List of Books
07. Academic Detail of Course MCA 103:Programming and Problem Solving in C
(i) Course Contents
(ii) Lecture Plan with references
(iii) Unit wise blow up
(iv) Previous Univ. Exam Paper
(v) Model paper
(vi) List of Books
08. Academic Detail of Course MCA 104: Computer organization and Assembly Language
Programming
(i) Course Contents
(ii) Lecture Plan with references
(iii) Unit wise blow up
(iv) Previous Univ. Exam Paper
(v) Model paper
(vi) List of Books
09. Academic Detail of Course MCA 105: Distributed Operating System
(i) Course Contents
(ii) Lecture Plan with references
(iii) Unit wise blow up
(iv) Previous Univ. Exam Paper
(v) Model paper
(vi) List of Books
10. Annexure: RGPV University MCA Exam Q. Paper
8/3/2019 SRM (2011) of I Sem
3/112
RAJIV GANDHI PROUDYOGIKI VISHWAVIDYALAYA(University of Technology of Madhya Pradesh)
Air Port Bypass Road
Gandhi Nagar, Bhopal-462 036
COURSE OF STUDY AND SCHEME OF EXAMINATION
MASTER OF COMPUTER APPLICATIONS (MCA)W.E.F. JULY 2010
MCA-I Sem
S
No
Subject
Code
Subject name Periods perweek
Credits Maximum Marks
(Theory slot)
Maximum
Marks
(Practical slot)
Total
L T P End
Sem
Exa
ms
Test
Two
Assig
nmen
ts/Qu
iz
End
Sem/P
ractica
l Viva
Practic
al
Record
/Assign
ment/Q
uiz/Pre
sentati
on
1 MCA-101 InformationTechnology
3 1 - 4 70 20 10 - - 1
2 MCA-102 MathematicalFoundation of
Computer Science
3 1 - 4 70 20 10 - - 1
3 MCA-103 Programming andProblem Solving in
C
3 1 - 4 70 20 10 - - 1
4 MCA-104 Computerorganization and
Assembly Language
Programming
3 1 - 4 70 20 10 - - 1
5 MCA-105 CommunicationSkills
3 1 - 4 70 20 10 - - 1
6 MCA-106 ProgrammingLaboratory in C
- - 8 8 - - - 120 80 2
7 MCA-107 Assembly LanguageProgramming
- - 2 2 - - - 30 20 5
Total 15 5 10 30 350 100 50 150 100 7
8/3/2019 SRM (2011) of I Sem
4/112
05 Academic Details of Course
MCA-101
Information Technology
8/3/2019 SRM (2011) of I Sem
5/112
(i) Course Content
UNIT-I
1. Basic concepts of IT
2. Concepts of Data & Info, data processing
3. History of computers (generation, type of languages)4. Organization of computers
5. I/O devices6. Storage devices
7. System software
8. Application software9. Utility packages
UNIT-II
1. Elements of assembly language programming
2. A simple assembly scheme3. Pass structure of assembler
4. Design of two passes assemblers
5. Design of two passes assemblers6. Macros & Macro Processors
UNIT-III
1. Aspects of compilation,
2. Memory allocation,
3. Compilation of expression &control structures4. Code optimization
5. Interpreters
6. Software tools for program development7. Editors & debug monitors
8. Programming environment
9. User interfaces
Course
No.
Course Name L
(Hrs)
T
(Hrs)
P
(Hrs)
Theory Slot Practical slot To
Ma
Theor
y
Marks
Test
Marks
Assign
ment/
Quiz
End
Sem/Prac
tical Viva
Practical
Record/Assignme
nt/Quiz/Presentation
MCA-
101
Information
Technology
3 1 - 70 20 10 - - 10
8/3/2019 SRM (2011) of I Sem
6/112
UNIT-IV
1. Relocation & linking concepts
2. Design of linkers
3. Self relocating programs4. A linker for MS DOS, linking for overlays
5. A two pass loader scheme
6. Relocating loaders7. Subroutine linkage
8. Direct linkage loader
9. Binders overlays
UNIT-V
1. Sequential file organization,
2. Random file organization,
3. Index structure,4. Indexed file organization,
5. Alternate key indexed sequential files,
6. Multi key organization,
7. Multi key access,8. Multi list file organization,
9. Inverted files & their definitions
8/3/2019 SRM (2011) of I Sem
7/112
(ii) Lecture Plan with references
Lect. Topics to be coveredDate of
CompletionRemarks
1.
Basic concepts of IT, Concepts of Data & Info, data
processing
R1 :1-5
2.History of computers (generation, type of languages) R1 :54 -
63
3.Organization of computers , I/O devices R1 :80
82
4.Storage devices R1 :103
5.
System software , Application software , Utility
packages
R1 :439 -
445
6.Elements of assembly language programming R2 :85
7.Elements of assembly language programming R2 :86
8.A simple assembly scheme R2 :91
9.Pass structure of assembler R2 :94
10.Design of two passes assemblers R2 :95
11.Design of two passes assemblers R2 :95
12. Macro definition & CallR2 :132
13. Macro expansion Nested macro calls R2 :133
Subject Title Information Technology Session :Jul 2011-
Dec 2011
Sub. Code MCA-101 Semester I
Department Department of MCA Branch MCA
8/3/2019 SRM (2011) of I Sem
8/112
14. Advanced macro facilitiesR2 :138
15. Design of macro processorsR2 :145
16. Aspects of compilation R2 :162
17. Memory allocation R2 :165
18. Compilation of expressionR2 :180
19. Compilation of control structuresR2 :192
20. Code optimizationR2 :199
21. InterpretersR2 :212
22. Software tools for program development R2 :250
23. Editors, debug monitorsR2:257,260
24.Programming environment, user interfaces. R2 :262
25.Relocation & linking concepts , Design of linkers R2 :223
26.Self relocating programs R2 :232
27. A linker for MS DOS R2 :245
28.A two pass loader scheme Notes
29.Relocating loaders Notes
30.Subroutine linkage , Notes
31. Direct linkage loader Notes
32. Binders overlaysNotes
33.Sequential file organization , Random file organization, R3 :92
34.Index structure R4 :156 -
164
35.Indexed file organization R3 :93
36.Alternate key indexed sequential files R3 :105
8/3/2019 SRM (2011) of I Sem
9/112
37. Direct file organizationR3 :106 -
113
38.Multi key organization , Multi key access R3: 115
39.Multi list file organization, R3: 116 -
118
40.Inverted files & their definitions
R3:118-
120
Books References
R1: Computers Today Suresh K Basandara Galgotia Publication
R2 :System Programming & Operating Systems D M Dhandhere Tata McGraw Hill Publication
R3 :An Introduction to Database Systems Bipin C Desai Galgotia Publication
R4 :Fundamentals of Database Systems Elmarsi & Navathe Pearson Education
8/3/2019 SRM (2011) of I Sem
10/112
(iii) Unit wise blow up
Unit I
1. Data: A representation of facts, concepts, or instructions in a formalized manner suitable
for communication, interpretation, or processing by humans or by automated means.
2. Information: Information is the result of processing, manipulating and organizing data in a
way that adds to the knowledge of the person receiving it.
3. Generation of Computer: The computer has experienced five generations, with the fifth
generation still very much in development.
-First Generation
-Second Generation-Third Generation
-Fourth Generation
-Fifth Generation
4. I/O DevicesInput device
Keyboard MouseMICR OCR
OMR Light Pen
Output Unit
VDU (Monitor) Printer Plotter
5. Storage Devices
Hard Disk
Magnetic Tape
Floppy Disk Optical Disk
Punched Card
6. System Software
Compiler
Interpreter
Operating System
7. Application Software
Databases
Word processors
Spreadsheet
http://doit.ort.org/course/gen_cpu/116.htmhttp://doit.ort.org/course/gen_cpu/116.htmhttp://doit.ort.org/course/gen_cpu/117.htmhttp://doit.ort.org/course/gen_cpu/118.htmhttp://doit.ort.org/course/gen_cpu/119.htmhttp://doit.ort.org/course/gen_cpu/120.htmhttp://doit.ort.org/course/gen_cpu/117.htmhttp://doit.ort.org/course/gen_cpu/118.htmhttp://doit.ort.org/course/gen_cpu/119.htmhttp://doit.ort.org/course/gen_cpu/120.htmhttp://doit.ort.org/course/gen_cpu/116.htm8/3/2019 SRM (2011) of I Sem
11/112
Unit II
1. Basic elements of assembly language are:
Labels
Instructions
Operands Directives Comments.
2. Assembly Scheme
Synthesis Phase
Analysis Phase
3. Pass structure of assembler
Single Pass Assembler
Two Pass Assembler
4. Macros: A macro is a group of repetitive instructions in a program which are codified onlyonce and can be used as many times as necessary.
Syntax of a Macro
The parts which make a macro are:
Declaration of the macro
Code of the macro
Macro termination directive
5. Nested Macro Call: A model Statement in a macro may constitute a call on another macro.
Such calls are known as nested macro call.Advanced Macro facilities
Alteration of flow of control
Expansion time variables
Attributes of parameters
8/3/2019 SRM (2011) of I Sem
12/112
Unit III
1. Aspects of Compilation:Two Aspects of Compilation
Generate code to implement meaning of a source program
Provide diagnostics for violations of PL semantics in a source program
2. Memory Allocation:Memory Allocation involves three important tasks
Determine amount of memory required
Use an appropriate memory allocation model
Determine appropriate memory mapping
3. Compilation of Expression:
Major issues in code generations for expressions are follows
Determination of an evaluation order for the operatorsSelection of instructions to be used in the target code
Use of registers and handling of partial results
4. Compilation of control structures
Control Transfer
Conditional ExecutionIterative Constructs
5. Code Optimization: Code optimization aims at improving the executionefficiency of a program. This is achieved in two ways
Redundancies in a program are eliminated
Computations in a program are rearranged or rewritten
Optimizing transformations commonly used in compiler are
Compile time evaluation
Elimination of common sub expressions
Dead code elimination
Frequency reduction
Strength reduction
6. Phases of Optimization: Local Optimization
Global Optimization
7. Software tools for program development
Program design, coding & documentation
Preparation of programs in machine readable form
Program translation, linking and loading
Program testing and debugging
Performance tuning
8/3/2019 SRM (2011) of I Sem
13/112
Reformatting the data
8. Editors :
Line Editors
Steam Editors
Screen Editors
Word Processors Structure Editors
9. Debug Monitors :Debug Monitor Provide following facilities
o Setting Breakpoint in the program
o Initiating a debug conversation when control reaches a breakpoint
o Displaying values of variables
o Assigning new values to variables
Testing user defined assertions and predicates involving program variables
10. Programming EnvironmentIt consists of the following components
Syntax Directed Editor
Language ProcessorDebug Monitor
Dialog Monitor
11. User InterfacesIt consists of two components
o Dialog Manager
o Presentation Manager
Unit IV
1. To execute an object program, we needsRelocation, which modifies the object program so that it can be loaded at an address
different from the location originally specified
Linking, which combines two or more separate object programs and supplies the
information needed to allow references between them?
Loading and Allocation, which allocates memory location and brings the object program
into memory for execution
2. Type of loaders
Assemble-and-go loader
Absolute loader (bootstrap loader)
8/3/2019 SRM (2011) of I Sem
14/112
Relocating loader (relative loader)
Direct linking loader
3. Design options
Linkage editors Dynamic linking
Bootstrap loaders
4. Linker: A program that pulls other programs together so that they can run.
Most programs are very large and consist of several modules.
Even small programs use existing code provided by the programming environment calledlibraries.
The linker pulls everything together, makes sure that references to other parts of the
program (code) are resolved.
5. Loading : Copying a program from a storage device to memory, then starting execution
6. Absolute Loader : Purpose
Load an absolute program into memory
Procedure (one pass over SIC obj. program)
1. Check Header record for program name, required space for program2. Instructions in each Text record loaded into memory at indicated address
3. on reaching End record, jump to the indicated address and start execution
8/3/2019 SRM (2011) of I Sem
15/112
Unit V
1. File : A file is organized logically as a sequence of records.
2. Records : A record is a sequence offields
Fixed-length
Variable-length
Spanned
Unspanned
3. Types of File :
Serial File
Sequential File
Index Sequential File Direct File
Secondary Key Retrieval File
-Multi list file organization
-Inverted file Organization
4. Ordered Indexes: An ordered file that stores the index field and a pointer. Requires a binarysearch on the index file
Types of Ordered Indexes
Primary
Clustering
Secondary
5. Secondary Indexes: A secondary index is an ordered file that stores the noordering field of a data file and a pointer. If the indexing field is a secondary or candidate
key, then the index is dense. If the indexing field is a nonkey field, then the index is sparse.
Introduces the idea of adding a level of indirection
8/3/2019 SRM (2011) of I Sem
16/112
(iv) university paper
8/3/2019 SRM (2011) of I Sem
17/112
8/3/2019 SRM (2011) of I Sem
18/112
8/3/2019 SRM (2011) of I Sem
19/112
(v) Model Test Paper
MCA-101
Information Technology
Time: 3 hr Max Marks: 100
Min Marks: 40Note: Attempt all. And each question carry equal marks.
Unit - I
Q1. (a) Draw the Block diagram of a digital computer and discuss its various components.
(b) Distinguish between primary memory and secondary memory
OR
(a) Define data processing and discuss the steps involved in data processing.(b) Distinguish between application software and System software.
Unit II
Q2 (a) Explain various types of assembly language statement.
(b) Write algorithm and flow chart of Pass I of two pass assemblerOR
(a)What are literals? How are they handled during assembly?(b) What is Macro and macro definition?
Unit III
Q3. (a) What do you understand by Memory allocation in compilation process?
(b) Explain software tools. Discuss software tools for program development.
OR
(a) What is Compiler? Discuss compilation process in detail.
(b) Explain code optimization. What are the ways in which code optimization can be achieved?
Unit IV
Q4 (a) What are loaders? Explain various loading schemes.
(b) What is Object module? Explain its various components.
OR
(a) Explain following terms
(i) Link Origin(ii) Load Origin
(iii) Link Address
(iv) Translated Origin
(b) Explain functions of Linker.
Unit V
Q5 (a) Explain sequential file organization .What are its advantages and disadvantages?
(b) Explain following terms1. File Header
2. Sparse & Dense Index
3. Spanned & Unspanned record OR
(a) Explain Indexing. What is primary index and secondary index?
(b) Differentiate between DBMS and file organization.
8/3/2019 SRM (2011) of I Sem
20/112
(vii) List of Books
1. D.M. Dhamdhere System Programming & O.S. 2nd Ed., Tata Mc. Graw Hill.
2. J. Donovan System Programming THM.
3. Rajaraman V. Fundamental of Computers (4nd edition.) Prentice Hall of India, New Delhi
2004.
4. Sardes D.H. Computers today McGraw Hill 1988.
5. S.Jaiswal, Fundamental of Computer & IT, Wiley dreamtech India..
Web References
1. http://doit.ort.org/course/intro.htm
2. http://www.mikroe.com/en/books/picbook/3_chapter.htm#3.2%20Assembly%20language
%20elements
3. http://cs.bbsbec.org/new_site/qbank/dataware%20housing.pdf
8/3/2019 SRM (2011) of I Sem
21/112
06 Academic Details of Course
MCA-102
Mathematical Foundation of Computer Science
8/3/2019 SRM (2011) of I Sem
22/112
(i) Course Content
UNIT-I
Sets, Relations and Functions:
1. Sets
2. Subsets Power sets3. Complement, Union and Intersection, Demorgans law Cartesian products
4. Relations, relational matrices, properties of relations
5. Equivalence relation,6. Functions , Injection, Surjection and Bijective mapping, Composition of functions
7. The characteristic functions
8. Mathematical induction.
UNIT-II
Proportions & Lattices:
1. Proposition & prepositional functions, Logical connections
2. Truth-values and Truth Table,3. The algebra of prepositional functions-4. The algebra of truth values
5. Applications (switching circuits, Basic Computer Components).
6. Partial order set, Hasse diagrams, upper bounds, lower bounds
7. Maximal and minimal element, first and last element8. Lattices, sub lattices, Isotonicity
9. Distributive inequality
10. Lattice homomorphism, lattice isomorphism ,11. Complete lattice ,complemented lattice
12. Distribution lattice.
UNIT-III
Groups and Fields:
1. Group axioms
2. Permutation group3. Sub group,
4. Co-sets,
5. Normal subgroup, Semi group
Course
No.
Course Name L
(Hrs)
T
(Hrs)
P
(Hrs)
Theory Slot Practical slot To
Ma
Theor
y
Marks
Test
Marks
Assign
ment/
Quiz
End
Sem/Prac
tical Viva
Practical
Record/Assignme
nt/Quiz/Presentation
MCA-
102
Mathematical
Foundation of
Computer
Science
3 1 - 70 20 10 - - 10
8/3/2019 SRM (2011) of I Sem
23/112
6. Lagrange theorem
7. Fields
8. Minimal polynomials9. Reducible polynomials
10. Primitive polynomial
11. Polynomial roots12. Applications.
UNIT-IV
Graphs:
1. Finite graphs
2. Incidence and degree
3. Isomorphism, sub graphs4. Union of graphs
5. Connectedness, walk, paths, and circuits
6. Eulerian graphs
7. Tree properties of trees8. Pendant vertices in tree, center of tree
9. Spanning trees and cut vertices10. Binary tree
11. Matrix representation of graph, incidence and adjacency matrix
12. Applications and properties of graphs in computer science.
UNIT-V
Discrete Numeric function and Recurrence relation:
1. Introduction to discrete numeric functions
2. Generating functions3. Introduction to recurrence relations4. Recursive algorithms
5. Linear recurrence relations with constant coefficients
6. Homogeneous solutions7. Particular solutions
8. Total solutions
8/3/2019 SRM (2011) of I Sem
24/112
(iii) Lecture Plan with references
Lect. Topics to be coveredDate of
CompletionRemarks
1. Sets, Subsets, Power sets R1:2
2. Complement, Union and IntersectionR1:6
3. Demorgans law and Cartesian productsR1:103
4. Relations, relational matrices, properties of relations R1:103
5. Equivalence relation R1:113
6. Functions ,Injection, Surjection and Bijective mapping,R1:126
7. Composition of functions, the characteristic functionsR1:134
8. Mathematical induction R1:14-18
9.Proposition & prepositional functions, Logical
connections
R1:28
10. Truth-values and Truth TableR1:29
11. The algebra of prepositional functionsR:29
12. The algebra of truth values Notes
13.Applications (switching circuits, Basic ComputerComponents).
R1:415
14.Partial order set, Hasse diagrams, R1:117
15. Upper bounds, lower boundsR1:119
Subject Title Mathematical Foundation of Computer Science Session :Jul 2011-Dec 2011
Sub. Code MCA-102 Semester I
Department Department of MCA Branch MCA
8/3/2019 SRM (2011) of I Sem
25/112
16. Maximal and minimal element, first and last element R1:118
17. Lattices, sub latticesR1:118-
393
18.Isotonicity , distributive inequality. Notes
19. Lattice homomorphism, lattice isomorphism R1:365
20. Complete lattice ,complemented latticeR1:395
21.Distribution lattice. R1:393
22. Group axiomsR1:346 -
R2:300
23. Permutation group, sub groupR1:354
24. Co-sets, normal subgroup
R2:322
R3:356
25. Semi group, Lagrange theoremR1:344
-353
26. Fields, minimal polynomialsR1:372
27. Reducible polynomials, R1:376
28. Primitive polynomial R1:377
29. Polynomial roots, applicationsR1:371
30. Finite graphs, incidence and degreeR1:139
31. Isomorphism, sub graphs and union of graphs R3:197
32. Connectedness, walk, paths, and circuitsR1:145
33. Applications of graphs in computer scienceNet
34. Eulerian graphs ,tree properties of trees R3:204
35. Pendant vertices in tree, center of tree , R1:139
36. Spanning trees and cut vertices, binary tree
R1:205-
210
37.Matrix representation of graph, incidence ,adjacency
matrix
Notes
38.
Their properties, applications of graphs in computer
science.
Notes
39. Introduction to discrete numeric functionsR2:504
8/3/2019 SRM (2011) of I Sem
26/112
40. Introduction to generating functions R2:506
41.Introduction to recurrence relations and recursivealgorithms
R2:531
42. Recursive algorithms Notes
43. Linear recurrence relations with constant coefficientsR2:558
44. Homogeneous solutionsR1:308
45.Particular solutions and total solutions R1:312,31
4
Reference Books
R1: Element of Discrete Mathematics: C.L. Liu
R2: Foundation Of Discrete Mathematics: K.D Joshi
R3: Discrete Mathematical Structure: Bernard Kolman.
8/3/2019 SRM (2011) of I Sem
27/112
(iv) Unit wise blow up
Unit-I
1. Set: A well Defined Collection or class of object is a set. Every object in a set is called an element.2. Different types of Sets:
Null or Empty Set
Singleton Set
Finite Set
Infinite Set
Subset
Proper Subset
Improper Set
Power set
Universal set
3.Mathematical Induction (A certain theorem P(n) is true for all nN, provided
It is true for n=1 i.e P (1) is true.
It is true for n=m+1 i.e n=m P(m) is trueP(m+1) is true.
4. Relation: Let A and B be two set. A relation from a A to B is a subset of A X B and is denoted by R
So R A X B.
1. Properties of Relation
Reflexive : if (a ,a) A
Symmetric : if (a,b)
A
(b,a)
A
Anti symmetric: if (a,b) A and (b,a) A a=b
Asymmetric: if (a,b) A and (b,a) A
Transitive: if (a,b) A and (b,c) A (a,c) A
2. Equivalence Relation: If relation has following property
8/3/2019 SRM (2011) of I Sem
28/112
Reflexive
Symmetric
Transitive
5.Function: A subset of A X B is called A function or Mapping from A to B if to every element of A
there is associated an unique element of B. Such that (x,y) f, i.e f A X B.
Kinds of Mapping
Onto or Surjective : F(A)= B
Into mapping: F(A) B
One to one or Injective : F(x1)= F(x2) x1= x2 Many one mapping: F(x1) F(x2) x1 x2 Bijective: Mapping which is One-one and onto.
6. Characteristic Function Of a Set:
Let A be any subset of the universal set U. Then the real valued Function
A : U {0,1} defined by
A(x) :
Axi f
Axi f
,,0
,,1
is called the Characteristic Function of the set.
Unit II
1. Boolean algebra is a setA, supplied with twobinary operations (called AND), (called
OR), a unary operation (called NOT) and two distinct elements 0 (called zero) and 1 (called one),
such that, for all elements a, b and c of setA, the following axiomshold:
associativity
commutativity
absorption
distributivity
complements
2. Truth Values and Truth table :
http://en.wikipedia.org/wiki/Sethttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Unary_operationhttp://en.wikipedia.org/wiki/Axiomshttp://en.wikipedia.org/wiki/Associativityhttp://en.wikipedia.org/wiki/Commutativityhttp://en.wikipedia.org/wiki/Absorption_lawhttp://en.wikipedia.org/wiki/Distributivityhttp://en.wikipedia.org/wiki/Complemented_latticehttp://en.wikipedia.org/wiki/Sethttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Unary_operationhttp://en.wikipedia.org/wiki/Axiomshttp://en.wikipedia.org/wiki/Associativityhttp://en.wikipedia.org/wiki/Commutativityhttp://en.wikipedia.org/wiki/Absorption_lawhttp://en.wikipedia.org/wiki/Distributivityhttp://en.wikipedia.org/wiki/Complemented_lattice8/3/2019 SRM (2011) of I Sem
29/112
3. Negation :
Logical Negation
p p
F T
T F
4. Conjunction
Logical Conjunction
p q p q
F F F
F T F
T F F
T T T
5. Disjunction
Logical Disjunction
p q p q
F F F
F T T
T F T
T T T
6. Implication
Logical Implication
8/3/2019 SRM (2011) of I Sem
30/112
p q p q
F F T
F T T
T F F
T T T
3. Lattics : An algebra is called a lattice if is a nonempty set, and arebinary operations on ,
both and areidempotent, commutative, and associative, and they satisfy the absorption law. Let the
poset be a lattice. Set and . Then the algebra is a
lattice.
4. Hasse Diagram:A graphical rendering of apartially ordered set displayed via the cover
relation of thepartially ordered set with an implied upward orientation. A point is drawn for each
element of the poset, and line segments are drawn between these points according to thefollowing two rules:
1. If in the poset, then the point corresponding to appears lower in the drawing than the
point corresponding to .2. The line segment between the points corresponding to any two elements and of the poset is
included in the drawing iff covers or covers .
5. Partial order: A relation " " is a partial order on a set if it has:
1. Reflexivity: for all .2. Antisymmetry: and implies .
3. Transitivity: and implies .6. Totally Order Set: A total order (or "totally ordered set," or "linearly ordered set") is a set
plus a relation on the set (called a total order) that satisfies the conditions for apartial orderplusan additional condition known as the comparability condition. A relation is a total order on a set
(" totally orders ") if the following properties hold.1. Reflexivity: for all .
2. Antisymmetry: and implies .
3. Transitivity: and implies .
4. Comparability (trichotomy law): For any , either or .
7. Distributive Lattics: A lattice which satisfies the identities
is said to be distributive.
http://mathworld.wolfram.com/Algebra.htmlhttp://mathworld.wolfram.com/NonemptySet.htmlhttp://mathworld.wolfram.com/BinaryOperation.htmlhttp://mathworld.wolfram.com/Idempotent.htmlhttp://mathworld.wolfram.com/Commutative.htmlhttp://mathworld.wolfram.com/Associative.htmlhttp://mathworld.wolfram.com/AbsorptionLaw.htmlhttp://mathworld.wolfram.com/Poset.htmlhttp://mathworld.wolfram.com/PartiallyOrderedSet.htmlhttp://mathworld.wolfram.com/CoverRelation.htmlhttp://mathworld.wolfram.com/CoverRelation.htmlhttp://mathworld.wolfram.com/PartiallyOrderedSet.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://mathworld.wolfram.com/Relation.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/TotalOrder.htmlhttp://mathworld.wolfram.com/PartialOrder.htmlhttp://mathworld.wolfram.com/Relation.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/TrichotomyLaw.htmlhttp://mathworld.wolfram.com/Lattice.htmlhttp://mathworld.wolfram.com/Algebra.htmlhttp://mathworld.wolfram.com/NonemptySet.htmlhttp://mathworld.wolfram.com/BinaryOperation.htmlhttp://mathworld.wolfram.com/Idempotent.htmlhttp://mathworld.wolfram.com/Commutative.htmlhttp://mathworld.wolfram.com/Associative.htmlhttp://mathworld.wolfram.com/AbsorptionLaw.htmlhttp://mathworld.wolfram.com/Poset.htmlhttp://mathworld.wolfram.com/PartiallyOrderedSet.htmlhttp://mathworld.wolfram.com/CoverRelation.htmlhttp://mathworld.wolfram.com/CoverRelation.htmlhttp://mathworld.wolfram.com/PartiallyOrderedSet.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://mathworld.wolfram.com/Relation.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/TotalOrder.htmlhttp://mathworld.wolfram.com/PartialOrder.htmlhttp://mathworld.wolfram.com/Relation.htmlhttp://mathworld.wolfram.com/Set.htmlhttp://mathworld.wolfram.com/TrichotomyLaw.htmlhttp://mathworld.wolfram.com/Lattice.html8/3/2019 SRM (2011) of I Sem
31/112
8. Modular Lattic: A lattice which satisfies the identity
is said to be modular.
Unit III
1. Group : An algebraic structure (G,o), where g is a non-empty set and o is a binary operation
defined on G is called a group if satisfied the following axiom:
G1: Closure property: aG and bG aob GG2: Associatively property: (aob)oc=ao(boc)a,b,c GG3: Existence of Identity: e G, eoa = aoe = a,a GG4: Existence of Inverse: a G, there exist a-1 a-1oa=e=ao a-1
2. Coset : Let G be a group on which the group operation is multiplication and H be a subgroup.
Let a be any element of G then the set ,,
Ha= {ha:h H} is called a right coset of H in G generate by a.Ha= {ah:h H} is called a Left coset of H in G generate by a.
3. Permutation: A one one mapping of a finite set S onto itself is called Permutation. The number
of element in the finite set S is called the degree of permutation.
f:SS then fis a permutation of degree n. Let f(a1)=b1,
f(an)=bn where { b1,b2,..bn } = { a1, a2,..an }
4. A subgroup is a subset ofgroupelements of a group that satisfies the fourgroup
requirements. It must therefore contain theidentity element. " is a subgroup of " is written, or sometimes
The orderof any subgroup of a groupoforder must be a divisorof .
A subgroup of a group that does not include the entire group itself is known as aproper
subgroup, denoted or .
Normal Subgroup: Let be asubgroup of a group . The similarity transformation of by
a fixed element in notin always gives a subgroup. If
5. Semi group : is an algebraic structure consisting of a setSclosed underan associativebinary operation. In other words, a semigroup is an associative magma.
The terminology is derived from the anterior notion of a group.The operation of a
semigroup is most often denoted multiplicatively, that is, or simplyxy denotes theresult of applying the semigroup operation to the ordered pair (x,y).
http://mathworld.wolfram.com/Lattice.htmlhttp://mathworld.wolfram.com/Subset.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/IdentityElement.htmlhttp://mathworld.wolfram.com/IdentityElement.htmlhttp://mathworld.wolfram.com/IdentityElement.htmlhttp://mathworld.wolfram.com/GroupOrder.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/GroupOrder.htmlhttp://mathworld.wolfram.com/Divisor.htmlhttp://mathworld.wolfram.com/Divisor.htmlhttp://mathworld.wolfram.com/ProperSubgroup.htmlhttp://mathworld.wolfram.com/ProperSubgroup.htmlhttp://mathworld.wolfram.com/Subgroup.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/SimilarityTransformation.htmlhttp://mathworld.wolfram.com/Subgroup.htmlhttp://en.wikipedia.org/wiki/Algebraic_structurehttp://en.wikipedia.org/wiki/Sethttp://en.wikipedia.org/wiki/Associativehttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Magma_(algebra)http://en.wikipedia.org/wiki/Group_(algebra)http://mathworld.wolfram.com/Lattice.htmlhttp://mathworld.wolfram.com/Subset.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/IdentityElement.htmlhttp://mathworld.wolfram.com/GroupOrder.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/GroupOrder.htmlhttp://mathworld.wolfram.com/Divisor.htmlhttp://mathworld.wolfram.com/ProperSubgroup.htmlhttp://mathworld.wolfram.com/ProperSubgroup.htmlhttp://mathworld.wolfram.com/Subgroup.htmlhttp://mathworld.wolfram.com/Group.htmlhttp://mathworld.wolfram.com/SimilarityTransformation.htmlhttp://mathworld.wolfram.com/Subgroup.htmlhttp://en.wikipedia.org/wiki/Algebraic_structurehttp://en.wikipedia.org/wiki/Sethttp://en.wikipedia.org/wiki/Associativehttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Magma_(algebra)http://en.wikipedia.org/wiki/Group_(algebra)8/3/2019 SRM (2011) of I Sem
32/112
6. Lagranges Theorem: states that for any finite groupG, the order(number of
elements) of every subgroupHofG divides the order ofG.
The left cosets are the equivalence classes of a certain equivalence relation on G and thereforeform a partition ofG. If we can show that all cosets ofHhave the same number of elements, then
we are done, sinceHitself is a coset ofH. Now, ifaHand bHare two left cosets ofH, we can
define a mapf: aH bHby settingf(x) = ba-1
x. This map is bijective because its inverse isgiven byf-1(y) = ab-1y.
This proof also shows that the quotient of the orders |G| / |H| is equal to the index [G:H] (the
number of left cosets ofHin G). If we write this statement as|G| = [G:H] |H|.
6. A field is a commutative ring (F, +, *) such that 0 does not equal 1 and all elements ofFexcept
0 have a multiplicative inverse. The followingfield axioms.
Both + and * are associative
Both + and * are commutative
Multiplication distributes over addition
Zero is the additive identity, and one is the multiplicative identity, and these two constants are
different
Existence of additive and multiplicative inverses
7. Ring: Formally, a ring is an Abelian group (R, +), together with a secondbinary operation *such that for all a, b and c inR,
a * (b * c) = (a * b) * ca * (b + c) = (a * b) + (a * c)
(a + b) * c = (a * c) + (b * c)also, if there exists a multiplicative identity in the ring, that is, an element e such that for all a inR,a * e = e * a = athen it is said to be a ring with unity. The number 1 is a common example of a unity.
It is simple to show that any ring in which 1 = 0 must have just one element; any such ring iscalled a zero ring.
8. Integral domain is a commutative ring with an additive identity 0 and a multiplicative identity
1 such that 0 1, in which the product of any two non-zero elements is always non-zero (thezero-product property); that is, there are no zero divisors. Integral domains are generalizations of
the integers and provide a natural setting for studying divisibility. An integral domain is a
commutative domain.
http://en.wikipedia.org/wiki/Finite_grouphttp://en.wikipedia.org/wiki/Order_(group_theory)http://en.wikipedia.org/wiki/Subgrouphttp://en.wikipedia.org/wiki/Equivalence_classhttp://en.wikipedia.org/wiki/Equivalence_relationhttp://en.wikipedia.org/wiki/Bijectivehttp://en.wikipedia.org/wiki/Index_of_a_subgrouphttp://en.wikipedia.org/wiki/Commutative_ringhttp://en.wikipedia.org/wiki/Abelian_grouphttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Commutative_ringhttp://en.wikipedia.org/wiki/Zero-product_propertyhttp://en.wikipedia.org/wiki/Zero_divisorhttp://en.wikipedia.org/wiki/Integerhttp://en.wikipedia.org/wiki/Domain_(ring_theory)http://en.wikipedia.org/wiki/Finite_grouphttp://en.wikipedia.org/wiki/Order_(group_theory)http://en.wikipedia.org/wiki/Subgrouphttp://en.wikipedia.org/wiki/Equivalence_classhttp://en.wikipedia.org/wiki/Equivalence_relationhttp://en.wikipedia.org/wiki/Bijectivehttp://en.wikipedia.org/wiki/Index_of_a_subgrouphttp://en.wikipedia.org/wiki/Commutative_ringhttp://en.wikipedia.org/wiki/Abelian_grouphttp://en.wikipedia.org/wiki/Binary_operationhttp://en.wikipedia.org/wiki/Commutative_ringhttp://en.wikipedia.org/wiki/Zero-product_propertyhttp://en.wikipedia.org/wiki/Zero_divisorhttp://en.wikipedia.org/wiki/Integerhttp://en.wikipedia.org/wiki/Domain_(ring_theory)8/3/2019 SRM (2011) of I Sem
33/112
9. Irreducible Polynomial: For any fieldF, the ring ofpolynomials with coefficients inFis
denoted byF[x]. A polynomialp(x) inF[x] is called irreducible over Fif it is non-constant andcannot be represented as the product of two or more non-constant polynomials fromF[x].
Unit IV
1. Graph: Asimple graph can be thought of as a triple G=(V,E,I), where VandEare disjoint finite
sets andIis an incidence relation such that every element ofEis incident with exactly two distinct
elements ofVand no two elements ofEare incident to the same pair of elements ofV. We call Vthe
vertex setandEthe edge setofG.
2. Degree: The degree, d(v), of a vertex v is the number of edges with which it is incident. Two
vertices are adjacentif they are incident to a common edge.
3. Walk:A walkis an alternating sequence of vertices and edges, with each edge being incident to the
vertices immediately preceding and succeeding it in the sequence. A walk is closedif the initial
vertex is also the terminal vertex.The length of a walk is the number of edges in the sequencedefining the walk
4. Trail: A trailis a walk with no repeated edges.
5. Path: Apath is a walk with no repeated vertices
6. Circuit: Cycle/circuitis a closed trail with at least one edge and with no repeated vertices except
that the initial vertex is the terminal vertex.
7. Isomorphic Graph: Two graphs which contain the same number ofgraph verticesconnected in the
same way are said to be isomorphic. Formally, two graphs and with graph verticesare said to be isomorphic if there is apermutation of such that is in the set of
graph edges iff is in the set ofgraph edges .
8. Planner Graph: A planar graph is a graph that can be drawn so that no edges intersect (or that can
beembedded) in theplane
http://en.wikipedia.org/wiki/Field_(mathematics)http://en.wikipedia.org/wiki/Ring_(mathematics)http://en.wikipedia.org/wiki/Polynomialhttp://mathworld.wolfram.com/Graph.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/Permutation.htmlhttp://mathworld.wolfram.com/GraphEdge.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://mathworld.wolfram.com/GraphEdge.htmlhttp://en.wikipedia.org/wiki/Graph_(mathematics)http://en.wikipedia.org/wiki/Edge_(graph_theory)http://en.wikipedia.org/wiki/Embeddinghttp://en.wikipedia.org/wiki/Embeddinghttp://en.wikipedia.org/wiki/Plane_(mathematics)http://en.wikipedia.org/wiki/Field_(mathematics)http://en.wikipedia.org/wiki/Ring_(mathematics)http://en.wikipedia.org/wiki/Polynomialhttp://mathworld.wolfram.com/Graph.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/Permutation.htmlhttp://mathworld.wolfram.com/GraphEdge.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://mathworld.wolfram.com/GraphEdge.htmlhttp://en.wikipedia.org/wiki/Graph_(mathematics)http://en.wikipedia.org/wiki/Edge_(graph_theory)http://en.wikipedia.org/wiki/Embeddinghttp://en.wikipedia.org/wiki/Plane_(mathematics)8/3/2019 SRM (2011) of I Sem
34/112
9. Euler's formula states that if a finite, connected, planar graph is drawn in the plane without any
edge intersections, and v is the number of vertices, e is the number of edges andfis the number of
faces (regions bounded by edges, including the outer, infinitely-large region), then
v e +f= 2
10. Bipartite Graph:
A bipartite graph, also called a bigraph, is a set ofgraph verticesdecomposed into two disjoint sets suchthat no two graph vertices within the same set are adjacent. A bipartite graph is a special case of a k-
partite graph with . Bipartite graphs are equivalent to two-colorable graphs, and a graph is bipartite
iffall its cycles are of even length.
11. Tree: A graph is acyclic if it has no cycles. An acyclic graph is also called aforest. A tree is a
connected, acyclic graph. Thus every connected component of a forest is a tree. Aspanning tree of agraph G is a sub graph TofG which is a tree and which satisfies |V(T)|=V|(G)|.
12. Spanning Tree: A spanning tree of a connected graph G can also be defined as a maximal set of
edges ofG that contains no cycle, or as a minimal set of edges that connect all vertices
13. Eccentricity: Let G be a graph and v be a vertex ofG. The eccentricity of the vertex v is the
maximum distance from v to any vertex. That is, e(v)=max{d(v,w):w in V(G)}.
14. Center: The centerofG is the set of vertices of eccentricity equal to the radius. Hence,
center(G)={v in V(G):e(v)=radius(G)}.
15. Minimum spanning tree: A minimum spanning tree orminimum weight spanning tree is then
a spanning tree with weight less than or equal to the weight of every other spanning tree. Moregenerally, any undirected graph has a minimum spanning forest.
16. Kruskal's algorithm is an algorithm in graph theory that finds aminimum spanning tree for aconnected weighted graph.
17. Prim's algorithm is an algorithm in graph theory that finds a minimum spanning treefor a
connected weighted graph. This means it finds a subset of the edges that forms a treethat includes everyvertex, where the total weight of all theedges in the tree is minimized
http://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Glossary_of_graph_theory#Genushttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/k-PartiteGraph.htmlhttp://mathworld.wolfram.com/k-PartiteGraph.htmlhttp://mathworld.wolfram.com/k-PartiteGraph.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Edge_(graph_theory)http://en.wikipedia.org/wiki/Edge_(graph_theory)http://en.wikipedia.org/wiki/Tree_(graph_theory)http://en.wikipedia.org/wiki/Tree_(graph_theory)http://en.wikipedia.org/wiki/Vertexhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Glossary_of_graph_theory#Genushttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/GraphVertex.htmlhttp://mathworld.wolfram.com/k-PartiteGraph.htmlhttp://mathworld.wolfram.com/k-PartiteGraph.htmlhttp://mathworld.wolfram.com/Iff.htmlhttp://en.wikipedia.org/wiki/Algorithmhttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Graph_theoryhttp://en.wikipedia.org/wiki/Minimum_spanning_treehttp://en.wikipedia.org/wiki/Edge_(graph_theory)http://en.wikipedia.org/wiki/Tree_(graph_theory)http://en.wikipedia.org/wiki/Vertexhttp://en.wikipedia.org/wiki/Graph_theory8/3/2019 SRM (2011) of I Sem
35/112
Unit V
1. Discrete numeric functions(ornumeric functions): The functions whose domain is the set of naturalnumbers and whose range is the set of real numbers.
2. Thesum of two numeric functions is a numeric function whose value at ris equal to the sum of the
values of the two numeric functions at r.3. Theproductof two numeric functions is a numeric function whose value at ris equal to the product
of the values of the two numeric functions at r.
4. For a numeric function (a0, a1, a2, ..., ar, ...), we define an infinite series
a0 + a1z + a2z2
+ ... + arzr
+ ...
which is called thegenerating function of the numeric functiona.
Let a be a numeric function andA(z) is its generating function. Let b be a numeric functionsuch that
br =rar
for some constant . We haveB(z) =A(z).
LetA(z) be the generating function ofa. It follows thatziA(z) is the generating function of
Sia for any positive integeri.
Let c = a * b. We have C(z) =A(z)B(z).cr = a0br + a1br-1 + a2br-2+ ... + ar-1b1+ arb0
[zr]A(z)B(z) = (a0 + a1z + a2z2
+ + arzr
+ )
(b0 + b1z + b2z2
+ + brzr
+ ) = cr.
5. Solving Recurrence Relations: A linear homogeneous recurrence relation of degree k with constant
coefficients is a recurrence relation of the form:an = c1an-1 + c2an-2 + + ckan-k,
Where c1, c2, , ck are real numbers, and ck 0. A sequence satisfying such a
recurrence relation is uniquely determined by the recurrence relation and the k initial
conditions:a0 = C0, a1 = C1, a2 = C2, , ak-1 = Ck-1.
6. Characteristic equation Basically, when solving such recurrence relations, we try to find
solutions of the form an = rn, where r is a constant.an = rn is a solution of the recurrence relation
an = c1an-1 + c2an-2 + + ckan-kif and only if
rn = c1rn-1 + c2r
n-2 + + ckrn-k.
Divide this equation by rn-k and subtract the right-hand side from the left:
rk - c1rk-1 - c2r
k-2 - - ck-1r - ck = 0This is called the characteristic equation of the recurrence relation.
7. Let c1 and c2 be real numbers with c2 0. Suppose that r2 c1r c2 = 0 has only one root
r0. A sequence {an} is a solution of the recurrence relation an = c1an-1 + c2an-2 if and only if
an = 1r0n + 2nr0n, for n = 0, 1, 2, , where 1 and 2 are constants.
8/3/2019 SRM (2011) of I Sem
36/112
8. Non-homogeneous : A non homogeneous linear recurrence has the form def.
a0tn + a1tn1 + ... + aktnk= f(n)where f(n) 0. There is no known general solution technique for non homogeneous linearrecurrences. So we will solve recurrences of the form
a0tn + a1tn1 + ... + aktnk= bn
p(n)where p(n) is a polynomial in n.
9. Homogeneous linear recurrenc : A homogeneous linear recurrence equation with constantcoeffi-cients is an equation of the form.
a0tn + a1tn1 + ... + aktnk= 0
Its linear because every term ti appears in the first power and term n.
depends on a sequence of n i terms for an integer i.
Its homogeneous because it equals 0. .
and it has constant coefficients.
(v) University Paper
8/3/2019 SRM (2011) of I Sem
37/112
8/3/2019 SRM (2011) of I Sem
38/112
8/3/2019 SRM (2011) of I Sem
39/112
8/3/2019 SRM (2011) of I Sem
40/112
8/3/2019 SRM (2011) of I Sem
41/112
(v) Model Test Paper
MCA-102
Mathematical Foundation of Computer Science
Time : 3 hr Max Marks: 100
Min Marks: 40Note : Attempt all. And each question carry equal marks.
Q.1 (a) Define irreflexive, symmetric, antisymmetiric and Asymmetric relations.Let A= {1,2,3,4} Given an example of a relation R in /A which is :
(i) Neither symmetric nor anti symmetric.
(ii) Antisymmetric and reflexive but not transitive.
(iii) Transitive and reflexive but not antisymmetric.
(b) (i) Prove that by mathematical induction that2n < n! For all n 4
(ii) If f: X Y is one one and onto, then prove that f-1 : Y X is also
one one and onto.
OR
(c) Define characteristic function of a set. Prove the following set identifies usingcharacteristic function:
(i) )()()( CABACBA =
(ii) BABA = )(
(d) If A, B, C and D are any four sets then prove that(i) )()()( CABACBA =
(ii) )()()()( DBCADCBA =
Q2. (a) Define distributive and modular Lattices and show that the lattice show
in following fig is modular but not distributive.1
a
a c
0
(b) Show that the following are equivalences:(i) QQPQP )(~)(
(ii) PQQP ~~
(d) Find the sum of product forms of the following Boolean expression in three variable x1,x2 and x3.
(i) )()( 3121 xxxx
b
8/3/2019 SRM (2011) of I Sem
42/112
(ii) 21 xx
(e) Show that the set B= {0,1} with two binary operation + and * and s unary operation,defined on B by the following operation tables is a Boolean algebra.
Q3. (a) Give an example, intersection of two subgroup of a group is a
Subgroup. But union of two subgroup is not necessarily a subgroup.
(b) Prove that the composition of two semi group homomorphism is also a semi grouphomomorphism.
(c) Define field and prove that the set of complex number is a field with respect to ordinaryaddition and multiplication.or
(d) Prove that every cyclic group is an abelian group.
(e) Prove that the order of sub group of a finite group divides the order of group.
(f) Define group and show that if every element in a group is its own inverse then the groupmust be abelian.
Q4. (a) Define the following trems giving examples:
i. Simple graphii. Multigraph
iii. In degree and out degree
iv. Complete graphv. Isomphorhic graph
vi. Connected graph
(b) Find the shortest path for the following graph using Dijkstre 's algorithm.
or
(c) The maximum number of edges in a simple graph with n vertices is -n(n -1)/2.(d) Find the minimal spanning tree the weighted graph given, ahead in, using Kruskal's
algorithm and prisms algorithm..
0 1+
0 1
1 1
0
1
0 1
0 0
0 1
0
1
* a a`
0
1
1
0
8/3/2019 SRM (2011) of I Sem
43/112
Q5. (a) Use the characteristic equation to solve the following recurrences:(a) an = 5an1 6an2 for n _ 2 where a0 = 2, a1 = 5.
(b) an = 4an1 3an2 for n _ 2 where a0 = 1, a1 = 2.
(b) Determine the numeric function corresponding to the generating function
a) A(z) =241
2
z
b) A(z)= ( )25
65 ZZ
Z
+
(c) Determine the generating function of the numeric function ar where
ar =
,2
,2
r
r
if r is even.
If r is odd
(d) Let a be a numeric function such that
ar =
4,2
30,2
r
r
r
Determine S 2 a and S-2 a .
8/3/2019 SRM (2011) of I Sem
44/112
(vi) List of Books
1. J.P.Trembley & R.P.Manohar Discrete Mathematical Structure with applications to ComputerScience.
2. Kenneth H. Rosen-203 Discrete Math & its Applications 5th ed.
3. K.A. Ross and C.R.B. Writht Discrete Mathematics .
4. Bernard Kolman & Robert C. Busby Discrete Mathematical Structures for Computer Science.
5. D.C Agarwal Mathematical Foundation Of Computer Science .
6. Dr. R.S Agarwal Mathematical Foundation .
7. Saums Series Discrete Mathematics . 6th ed.
Web References
1. http://www.cosc.brocku.ca/~duentsch/archive/methprimer1.pdf
2. http://mason.gmu.edu/~asamsono/teaching/math125/Lecture2.pdf
3. http://www.math.duke.edu/~wka/math123S/set.pdf
4. http://en.wikipedia.org/wiki/Mathematical_induction
5. http://www.math.cl/induction.html
6. http://en.wikipedia.org/wiki/Proposition
7. http://math.chapman.edu/cgi-bin/structures.pl?Lattices
8. http://math.chapman.edu/cgi-bin/structures.pl?Semilattices
9. http://aips2.nrao.edu/docs/aips/implement/Lattices.html
10. http://www.ics.mq.edu.au/~chris/math136/chap02.pdf
11. http://www.ics.mq.edu.au/~chris/math136/chap02.pdf
12. http://en.wikipedia.org/wiki/Field_(mathematics)
13. http://www.mathreference.com/la-mpoly,min.html
14. http://www.imada.sdu.dk/Research/discrete_math.php
15. http://www.utm.edu/departments/math/graph/
16. http://cs.kaist.ac.kr/%7Ehyungkshin/bbs/data/cs204_lecturenote_2007s/ch_1_sets.pdf
17. http://www.cs.sunysb.edu/~algorith/lectures-good/node3.html
18. http://www.maths.usyd.edu.au/u/don/courses/math1904/lect18.pdf
http://www.cosc.brocku.ca/~duentsch/archive/methprimer1.pdfhttp://mason.gmu.edu/~asamsono/teaching/math125/Lecture2.pdfhttp://www.math.duke.edu/~wka/math123S/set.pdfhttp://en.wikipedia.org/wiki/Mathematical_inductionhttp://www.math.cl/induction.htmlhttp://en.wikipedia.org/wiki/Propositionhttp://math.chapman.edu/cgi-bin/structures.pl?Latticeshttp://math.chapman.edu/cgi-bin/structures.pl?Semilatticeshttp://aips2.nrao.edu/docs/aips/implement/Lattices.htmlhttp://www.ics.mq.edu.au/~chris/math136/chap02.pdfhttp://www.ics.mq.edu.au/~chris/math136/chap02.pdfhttp://en.wikipedia.org/wiki/Field_(mathematics)http://www.mathreference.com/la-mpoly,min.htmlhttp://www.imada.sdu.dk/Research/discrete_math.phphttp://www.utm.edu/departments/math/graph/http://cs.kaist.ac.kr/~hyungkshin/bbs/data/cs204_lecturenote_2007s/ch_1_sets.pdfhttp://www.cs.sunysb.edu/~algorith/lectures-good/node3.htmlhttp://www.cosc.brocku.ca/~duentsch/archive/methprimer1.pdfhttp://mason.gmu.edu/~asamsono/teaching/math125/Lecture2.pdfhttp://www.math.duke.edu/~wka/math123S/set.pdfhttp://en.wikipedia.org/wiki/Mathematical_inductionhttp://www.math.cl/induction.htmlhttp://en.wikipedia.org/wiki/Propositionhttp://math.chapman.edu/cgi-bin/structures.pl?Latticeshttp://math.chapman.edu/cgi-bin/structures.pl?Semilatticeshttp://aips2.nrao.edu/docs/aips/implement/Lattices.htmlhttp://www.ics.mq.edu.au/~chris/math136/chap02.pdfhttp://www.ics.mq.edu.au/~chris/math136/chap02.pdfhttp://en.wikipedia.org/wiki/Field_(mathematics)http://www.mathreference.com/la-mpoly,min.htmlhttp://www.imada.sdu.dk/Research/discrete_math.phphttp://www.utm.edu/departments/math/graph/http://cs.kaist.ac.kr/~hyungkshin/bbs/data/cs204_lecturenote_2007s/ch_1_sets.pdfhttp://www.cs.sunysb.edu/~algorith/lectures-good/node3.html8/3/2019 SRM (2011) of I Sem
45/112
07 Academic Details of Course
MCA-103
Programming and Problem Solving in C
8/3/2019 SRM (2011) of I Sem
46/112
(i) Course Content
(ii)
UNIT-I
An overview:
1. Problem identification,2. analysis, design, coding,
3. testing & debugging, implementation,4. modification & maintenance;
5. algorithms & flowcharts;
6. Characteristics of a good program - accuracy,7. simplicity, robustness, portability,
8. minimum resource & time requirement,
9. modularization; Rules/ conventions of coding,
10. documentation, naming variables;11. Top down design; Bottom-up design.
UNIT-II
1. Fundamentals of C Programming: History of C;
2. Structure of a C Program; Data types;
3. Constant & Variable, naming variables;4. Operators & expressions;
5. Control Constructs if-else, for, while, do-while;
6. Case switch statement; Arrays;7. Formatted & unformatted I/O;
8. Type modifiers & storage classes;
9. Ternary operator; Type conversion & type casting;
10. Priority & associativity of operators.
UNIT-III
1. Modular Programming: Functions; Arguments;2. Return value; Parameter passing call by value,
3. call by reference; Return statement;
4. Scope, visibility and life-time rules for various types of variable,5. static variable; Calling a function;
Course
No.
Course Name L
(Hrs)
T
(Hrs)
P
(Hrs)
Theory Slot Practical slot To
Ma
Theor
y
Marks
Test
Marks
Assign
ment/
Quiz
End
Sem/Prac
tical Viva
Practical
Record/Assignme
nt/Quiz/Presentation
MCA-
103
Programmin
g and
Problem
Solving in C
3 1 - 70 20 10 - - 10
8/3/2019 SRM (2011) of I Sem
47/112
6. Recursion basics, comparison with iteration,
7. types of recursion- direct, indirect,
8. tree and tail recursion,9. when to avoid recursion, examples.
UNIT-IV1. Advanced Programming Techniques:
2. Special constructs Break,
3. continue, exit(), goto & labels;4. Pointers - & and * operators,
5. pointer expression, pointer arithmetic,
6. dynamic memory management functions like malloc(),
7. calloc(), free(); String; Pointer v/s array;8. Pointer to pointer; Array of pointer & its limitation;
9. Function returning pointers;
10. Pointer to function, Function as parameter;
11. Structure basic, declaration,12. membership operator, pointer to structure,
13. referential operator, self referential structures,14. structure within structure,
15. array in structure, array of structures;
16. Union basic, declaration; Enumerated data type;
17. Typedef; command line arguments.
UNIT-V
1. Miscellaneous Features:2. File handling and related functions;
3. printf & scanf family;C
4. preprocessor basics, #Include, #define, #undef,5. conditional compilation directive like #if, #else, #elif, #endif, #ifdef and #ifndef;
6. Variable argument list functions.
8/3/2019 SRM (2011) of I Sem
48/112
(vi) Lecture Plan with references
Lect. Topics to be coveredDate of
Completion
Remar
ks
1. Problem identification,Notes
2.Analysis, design, coding, testing & debugging,
implementation
R3:8-11
3. Modification & maintenance, algorithms & flowcharts.Notes
4. Characteristics of a good program R3:50
5. Modularization; Rules/ conventions of coding, Notes
6. Documentation, naming variables R3:126
7. Top down design, Bottom-up design R3:134
8. Fundamentals of C Programming: History of C; R1:3-5
9. Structure of a C Program; Data types;R1:6-23
- 168
10. Constant & Variable, naming variables; R1:10
11. Operators & expressions;R1:50-
60
12.Control Constructs if-else, for, while, do-while; Caseswitch statement
R1:38-48
13. Arrays R1:213
14. Formatted & unformatted I/O;R1:316-
325
15. Type modifiers & storage classes; R1:174
16.Ternary operator; Type conversion & type casting;Priority & associatively of operators.
R1:565
Subject Title Programming and Problem Solving in C Session :Jul 2011-Dec 2011
Sub. Code MCA-103 Semester I
Department Department of MCA Branch MCA
8/3/2019 SRM (2011) of I Sem
49/112
17. Modular Programming: Functions; Arguments;R1:121
18.Return value; Parameter passing call by value,call by reference; Return statement;
R1:136-
140
19.
Scope, visibility and life-time rules for various types of
variable,
R1:135
notes
20.Static variable; Calling a function; Recursion basics,
comparison with iteration
R1:140-150
21.Types of recursion- direct, indirect, tree and tailrecursion.
Net
22. When to avoid recursion, examples. Net
23. Advanced Programming TechniquesR1:354
24. Special constructs BreakR2:322
R3(356)
25.Continue, exit(), goto & labels Pointers - & and *
operators,
R1:344
-353
26. Pointer expression, pointer arithmetic,R2:4-9
27. Dynamic memory management functions like malloc() R1:691
28. Calloc(), free(); String; Pointer v/s arrayR2: 27-
91
29. Pointer to pointer; Array of pointer & its limitation;R2:33-
43
30. Function returning pointers R1:96
31. Pointer to function, Function as parameter;R1:141
R3:97
32.Structure basic, declaration, membership operator,
pointer to structure
R1:290
R2:135
33. Structure basic, declaration,R1:290-
296
34. Membership operator, pointer to structure,R3:204R2:140
35.Structure within structure, array in structure, array of
structures;
R1:299
Notes
36. Union basic, declaration; Enumerated data type R1:517
37. Typedef; command line arguments R1:563
38. Miscellaneous Features:Notes
39. Variable argument list functions R1:10-
8/3/2019 SRM (2011) of I Sem
50/112
256
40. File handling and related functionsR1:349-
361
41. Printf & scanf family;CR1:27-
316-689
42. Preprocessor basics, #Include, #define, #undef
R1:208
43. conditional compilation directiveNotes
44. like #if, #else, #elif, #endif, #ifdef and #ifndefR1:202-
208
45. Tutorial Notes
46. TutorialNotes
References Books
R1:Kanetkar Y. Let us C, BPB.
R2:Kanetkar Y.: Pointers in C , BPB
R3:Kerninghan & Ritchie The C programming language, PHI
8/3/2019 SRM (2011) of I Sem
51/112
(iii) Unit wise blow up
Unit-I
1. Problem identification: Steps in the Process
What bothers you about some problem?
Does it vary? Can you name the relevant concepts?
Can you name the most important ones?
Can you hypothesize an answer?
Is your problem part of a larger problem?
Can you state a relationship between variables
Can you collect data and test that statement?
2. Analysis: The existing system is evaluated. Deficiencies are identified. This can be done by
interviewing users of the system and consulting with support personnel.
3. Design: The proposed system is designed. Plans are laid out concerning the physicalconstruction, hardware, operating systems, programming, communications, and security issues.
4. Coding: The new system is developed. The new components and programs must be obtained
and installed. Users of the system must be trained in its use, and all aspects of performance mustbe tested. If necessary, adjustments must be made at this stage.
5. Testing & debugging: Testing of parts of software, especially where code by two different
engineers must work together falls to the software engineer. Testing the developed system
Write the test conditions test conditions are conducted by comparing expected
outcomes to actual outcomes. If these differ, a bug is generated and a backtrack to the
development stage must occur.
6. Implementation: Reducing a design to code may be the most obvious part of the softwareengineering job, but it is not necessarily the largest portion.
7. Modification & maintenance: Maintaining and enhancing software to cope with newlydiscovered problems or new requirements can take far more time than the initial development of
the software. Not only may it be necessary to add code that does not fit the original design but
just determining how software works at some point after it is completed may require significant
effort by a software engineer. About of all software engineering work is maintenance, but thisstatistic can be misleading. A small part of that is fixing bugs. Most maintenance is extending
systems to do new things, which in many ways can be considered new work. In comparison,
about of all civil engineering, architecture, and construction work is maintenance in a similarway.
8. Algorithms & flowcharts: An Algorithm is just a detailed sequence of simple steps that are needed to solve a problem.
A Flowchart is a graphical representation of an algorithm
9. Characteristics of a good program: Accuracy, simplicity, robustness, portability, minimum
resource & time requirement, modularization
8/3/2019 SRM (2011) of I Sem
52/112
10. Documentation: An important (and often overlooked) task is documenting the internal design of
software for the purpose of future maintenance and enhancement. Documentation is mostimportant for external interfaces.
11. Naming variables:
(1) Variable name must begin with Alphanumeric character or underscore character(_), followed by one or more Alphanumeric character
(2) Don't put spaces on either side of the equal sign when assigning value tovariable. For e.g. In following variable declaration there will be no error
(3) Variables are case-sensitive, just like filename in Linux.
(4) You can define NULL variable as follows (NULL variable is variable which has
no value at the time of definition)
(5) Do not use?,* etc, to name your variable names
12. Top down design: In a top-down approach an overview of the system is first formulated
specifying but not detailing any first-level subsystems. Each subsystem is then refined in yet
greater detail, sometimes in many additional subsystem levels, until the entire specification isreduced to base elements. A top-down model is often specified with the assistance of "black
boxes" that make it easier to manipulate. However, black boxes may fail to elucidate elementary
mechanisms or be detailed enough to realistically validate the model.13. Bottom-up design: In a bottom-up approach the individual base elements of the system are first
specified in great detail. These elements are then linked together to form larger subsystems,
which then in turn are linked, sometimes in many levels, until a complete top-level system is
formed. This strategy often resembles a "seed" model, whereby the beginnings are small, buteventually grow in complexity and completeness. However, "organic strategies", may result in a
tangle of elements and subsystems, developed in isolation, and subject to local optimization as
opposed to meeting a global purpose.
UNIT-II
1. History of C:The milestones in C's development as a language are listed below:
UNIX developed c. 1969 -- DEC PDP-7 Assembly Language BCPL -- a user friendly OS providing powerful development tools developed from BCPL.
Assembler tedious long and error prone. A new language ``B'' a second attempt. c. 1970. A totally new language ``C'' a successor to ``B''. c. 1971 By 1973 UNIX OS almost totally written in ``C''.
2. Structure of a C Program:
A C program basically has the following form: Preprocessor Commands
Type definitions Function prototypes: declare function types and variables passed to function. Variables
Functions
3. Data types:
C has the following simple data types:
8/3/2019 SRM (2011) of I Sem
53/112
4. Constant & Variable:
C has four fundamental types of variables: int integer (PDP-11: 16 bits; H6070: 36 bits; IBM360: 32 bits) char one byte character (PDP-11, IBM360: 8 bits; H6070: 9 bits)
float single-precision floating point double double-precision floating point
All variables in a C program must be declared, although this can sometimes be done implicitlyby context. Declarations must precede executable statements. The declaration
int a, b, c, sum;Declares a, b, c, and sum to be integers.A constantis just an immediate, absolute value found in an expression. The simplest
constants are decimal integers, e.g. 0, 1, 2, 123 . Occasionally it is useful to specify
constants in base 8 or base 16 (octal or hexadecimal); this is done by prefixing an extra 0(zero) for octal, or 0x for hexadecimal: the constants 100, 0144, and 0x64 all represent
the same number. (If you're not using these non-decimal constants, just remember not to
use any leading zeroes. If you accidentally write 0123 intending to get one hundred and
twenty three, you'll get 83 instead, which is 123 base 8.)
5. Naming variables:Variable names have one to eight characters, chosen from A-Z, a-z, 0-9, and
_, and start with a non-digit. Stylistically, it's much better to use only a single case and give
functions and external variables names that are unique in the first six characters. (Function andexternal variable names are used by various assemblers, some of which are limited in the size
and case of identifiers they can handle.) Furthermore, keywords and library functions may only
be recognized in one case.
6. Operators & expressions:
The following table shows the available arithmetic operators and the precedence each takes
within an arithmetic expression.
Arithmetic Operator Representation Precedence
** Exponentiation First
* Multiplication Second
/ Division Second+ Addition or identity Third
- Subtraction or negation Third
8/3/2019 SRM (2011) of I Sem
54/112
Logical Operators: Logical operators are usually used with conditional statements.The two basic logical operators are:
&& for logical AND, || for logical OR.7. Control Constructs if-else, for, while, do-while: The C language includes a wide variety of
powerful and flexible control statements. The most useful of these are described in the following.
The if-else statement is used to carry out a logical test and then take one of two possible actions,
depending on whether the outcome of the test is true or false. The else portion of the statement is
optional. Thus, the simplest possible if-else statement takes the form:
if (expression) statement
The general form of an if-else statement, which includes the else clause, is
if (expression) statement 1 else statement 2If the expression has a non-zero value (i.e., if expression is true) then statement1 is executed.
Otherwise, statement2 is executed.
The while statement is used to carry out looping operations, in which a group of statements isexecuted repeatedly until some condition is satisfied. The general form of a while statement iswhile (expression) statement
The statement is executed repeatedly, as long as the expression is nonzero ( i.e., as long as
expression is true). The statement can be either simple or compoundWhen a loop is constructed using a while statement, the test for the continuation of the loop is
carried out at the beginningof each pass. Sometimes, however, it is desirable to have a loop
where the test for continuation takes place at the endof each pass. This can be accomplished bymeans of a do-while statement. The general form of a do-while statement is
do statement while (expression);
The general form of a for statement is
for (expression 1; expression 2; expression 3) statementwhere expression1 is used to initialize some parameter (called an index) that controls the looping
action, expression2 represents a condition that must be true for the loop to continue execution,and expression3 is used to alter the value of the parameter initially assigned by expression1.
When a for statement is executed, expression2 is evaluated and tested at the beginning of each
pass through the loop, whereas expression3 is evaluated at the end of each pass.
8. Case switch statement: The switch-case statement is a multi-way decision statement. The value
of the expressions in a switch-case statement must be an ordinal type i.e. integer, char, short,long, etc. Float and double are not allowed. The syntax is:
switch( expression )
{case constant-expression1: statements1;
[case constant-expression2: statements2;]
[case constant-expression3: statements3;]
8/3/2019 SRM (2011) of I Sem
55/112
[default : statements4;]}
The case statements and the default statement can occur in any order in the switch statement. Thedefault clause is an optional clause that is matched if none of the constants in the case statements
can be matched.
9. Arrays: In C, it is possible to make arrays whose elements are basic types. Thus we can makean array of 10 integers with the declaration
int x[10];
The square brackets mean subscripting; parentheses are used only for function references. Array
indexes begin at zero, so the elements of x arex[0], x[1], x[2], ..., x[9]
If an array has n elements, the largest subscript is n-1.
Multiple-dimension arrays are provided, though not much used above two dimensions. Thedeclaration and use look like
int name[10] [20];
n = name[i+j] [1] + name[k] [2];Subscripts can be arbitrary integer expressions. Multi-dimension arrays are stored by row
(opposite to Fortran), so the rightmost subscript varies fastest; name has 10 rows and 20
columns.
10. Type modifiers & storage classes:
Type modifiers include: short, long, unsigned, signed. Not all combinations of types and
modifiers are available.Storage classes include: auto, extern, register, static.
The auto keyword places the specified variable into the stack area of memory. This is
usually implicit in most variable declarations, e.g. int i;
The extern keyword makes the specified variable access the variable of the same namefrom some other file. This is very useful for sharing variables in modular programs. The register keyword suggests to the compiler to place the particular variable in the fastregister memory located directly on the CPU. Most compilers these days (like gcc) are so
smart that suggesting registers could actually make your program slower. The static keyword is useful for extending the lifetime of a particular variable. If you
declare a static variable inside a function, the variable remains even after the function call islong gone (the variable is placed in the alterable area of memory). The static keyword is
overloaded. It is also used to declare variables to be private to a certain file only when
declared with global variables. static can also be used with functions, making those functionsvisible only to the file itself.
UNIT-III
1. Modular Programming:
Modular programming is a programming paradigm that was first presented by Information &
Systems Institute, Inc. at the National Symposium on Modular Programming in 1968.Modularity in computer science and programming is a principle, whereas Modular Programming
was "a set of techniques for achieving modularity
8/3/2019 SRM (2011) of I Sem
56/112
2. Functions; Arguments; Return value;
Almost all programming languages have some equivalent of the function. You may have metthem under the alternative names subroutine or procedure.
Some languages distinguish between functions which return variables and those which don't. C
assumes that every function will return a value. If the programmer wants a return value, this isachieved using the return statement. If no return value is required, none should be used when
calling the function.The c function tag lets you define a single return value and one or more input parameters passedto a function. As part of the function definition, you include the data type of the return value and
input parameters.
3. Parameter passing call by value, call by reference;
Call by ValueCalling mechanism
Arguments are evaluated for their values
Local variables created for each parameter
Values resulting from arguments copied to new parameter variables
When function call ends, parameter variables are discarded
During function execution, value of parameters may diverge from argument
values (function does not affect arguments)
Call by Reference
Calling mechanism
Variable locations for arguments determined
Parameter names added to the location for each argument
When function call ends, extra names are discarded
During function call, changes to referenced variables persist even after function
ends
4. Return statement:
The form of the return statement isreturn ["(" ["," ]* ")"]
The return statement terminates execution of the containing procedure or iterator. There must bethe same number of expressions as there are return result types listed in the routine's header, and
their types must be subtypes of the corresponding listed types. (If return is used in an iterator, no
results can be given; iterators do not have return result types.) The expressions (if any) are
evaluated in an unspecified order, and the objects obtained become the results of the procedure.
5. Scope, visibility and life-time rules for various types of variable:
The scope rules for modules define relationships among the names within the partitions. There
are four choices.
All local names visible globally.
All external names visible locally. Only local explicitly exported names visible globally.
Only external names explicitly imported are visible locally
6. Static variable:
The static variable is not destroyed on exit from the function, instead its value is preserved, andbecomes available again when the function is next called. Static variables are declared as local
variables, but the declaration is preceded by the word static
static int counter;
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000263.htm#2852457http://livedocs.adobe.com/coldfusion/7/htmldocs/00000263.htm#28524578/3/2019 SRM (2011) of I Sem
57/112
Static variables can be initialised as normal, the initialization is performed once only, when the
program starts up.
7. Calling a function;
The arguments passed to the functions have been passed by value. This means that when calling
a function with parameters, what we have passed to the function were copies of their values butnever the variables themselves. For example, suppose that we called our first function addition
using the following code:int x=5, y=3, z;
z = addition ( x , y );
What we did in this case was to call to function addition passing the values of x and y, i.e. 5 and3 respectively, but not the variables x and y themselves.
This way, when the function addition is called, the value of its local variables a and b become 5and 3 respectively, but any modification to either a or b within the function addition will not
have any effect in the values of x and y outside it, because variables x and y were not themselvespassed to the function, but only copies of their values at the moment the function was called.
8. Recursion basics:
Recursion is the process a procedure goes through when one of the steps of the procedure
involves rerunning the entire same procedure. A procedure that goes through recursion is said to
be recursive. Something is also said to be recursive when it is the result of a recursive procedure.A procedure is a set of steps that are to be taken based on a set of rules. The running of a
procedure involves actually following the rules and performing the steps.
9. Comparison with iteration:
When writing code to do repetitive tasks, the two primary approaches are iteration and recursion.
Generally you can use either one interchangeably, but potentially with different performance and
complexity.A recursive function calls itself (possibly more than once), with different parameters, and defines
an exit clause that is guaranteed to be reached.
An iterative function includes a loop, which iterates a pre-determined number of times, or checks
for an exit clause every time through.The advantages and disadvantages of the two are not always obvious, and you should really take
it on a case-by-case basis.
1. Recursion may be slower, and use greater resources, because of the extra function calls.2. Recursion may lead to simpler, shorter, easier-to-understand functions, especially for
mathematicians who are comfortable with induction formulae.
10. Types of recursion- direct, indirect, tree and tail recursion:
There are many ways to categorize a recursive function. Listed below are some of the most
common.
Linear RecursiveA linear recursive function is a function that only makes a single call to itself each time the
function runs (as opposed to one that would call itself multiple times during its execution). The
factorial function is a good example of linear recursion.
Another example of a linear recursive function would be one to compute the square root of anumber using Newton's method (assume EPSILON to be a very small number close to 0):
http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_16.html',%20'ea5769eba5',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_9.html',%20'2cfae2de3e',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_4.html',%20'1efb93075b',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_16.html',%20'ea5769eba5',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_9.html',%20'2cfae2de3e',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_4.html',%20'1efb93075b',%20'500',%20'500')8/3/2019 SRM (2011) of I Sem
58/112
double my_sqrt(double x, double a)
{double difference = a*x-x;
if (difference < 0.0) difference = -difference;
if (difference < EPSILON) return(a);else return(my_sqrt(x,(a+x/a)/2.0));
}Tail recursiveTail recursion is a form of linear recursion. In tail recursion, the recursive call is the last thing the
function does. Often, the value of the recursive call is returned. As such, tail recursivefunctions
can often be easily implemented in an iterativemanner; by taking out the recursive call and
replacing it with a loop, the same effect can generally be achieved. In fact, a good compiler canrecognize tail recursion and convert it to iteration in order to optimize the performance of the
code.
A good example of a tail recursive function is a function to compute the GCD, or GreatestCommon Denominator, of two numbers:
int gcd(int m, int n)
{int r;
if (m < n) return gcd(n,m);
r = m%n;
if (r == 0) return(n);
else return(gcd(n,r));}
Binary Recursive
Some recursive functions don't just have one call to themself, they have two (or more). Functions
with two recursive calls are referred to asbinary recursive functions.The mathematical combinations operation is a good example of a function that can quickly be
implemented as a binary recursive function. The number of combinations, often represented asnCkwhere we are choosing n elements out of a set of k elements, can be implemented as
follows:
int choose(int n, int k)
{if (k == 0 || n == k) return(1);
else return(choose(n-1,k) + choose(n-1,k-1));
}Exponential recursion
An exponential recursive function is one that, if you were to draw out a representation of all thefunction calls, would have an exponential number of calls in relation to the size of the data set(exponential meaning if there were n elements, there would be O(an) function calls where a is a
positive number).
A good example an exponentially recursive function is a function to compute all the
permutations of a data set. Let's write a function to take an array of n integers and print out everypermutation of it.
void print_array(int arr[], int n)
http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_18.html',%20'0cbf874007',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_5.html',%20'c6b82d13a4',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_5.html',%20'c6b82d13a4',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_8.html',%20'634e18af09',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_8.html',%20'634e18af09',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_2.html',%20'a71a352e57',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_10.html',%20'b0d01389dc',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_18.html',%20'0cbf874007',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_5.html',%20'c6b82d13a4',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_8.html',%20'634e18af09',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_2.html',%20'a71a352e57',%20'500',%20'500')http://scrollingpopup%28%27http//www.sparknotes.com/cs/recursion/whatisrecursion/terms/term_10.html',%20'b0d01389dc',%20'500',%20'500')8/3/2019 SRM (2011) of I Sem
59/112
{
int i;for(i=0; i
8/3/2019 SRM (2011) of I Sem
60/112
int is_odd(unsigned int n)
{return (!iseven(n));
}
I told you recursion was powerful! Of course, this is just an illustration. The above situation isn'tthe best example of wh