CH-1
CH-1
Subject Code:3150703
Subject credit:5
Prepared by:
Prof. Nishaba Jadeja
Teaching Scheme
Teaching Scheme Credits Examination Marks
4 0 2 5 70 30 30 20 150
[L-Lecture;
T – Tutorial/Teacher Guided Theory Practice;
P - Practical;
C – Credit,
ESE - End Semester Examination,
PA – Progressive Assessment]
Evaluation Methodology
Theory Exam Marks Marks Conversion
GTU External Exam 70 NA
Internal 20
Class Test 1 & 2,3 10
Lab performance 05
Google Classroom Code
2665apc
https://classroom.google.com/c/NjkzMjIxODIyMTc1?cjc=2665apc
Syllabus
• Total syllabus is covered in 09 topics.
• ADA-3150703 syllabus.pdf
CH-1
Basics of Algorithms and
Mathematics
Outlines
What is an algorithm?
Mathematics for Algorithmic Sets,
Functions and Relations,
Vectors and Matrices,
Linear Inequalities and
Linear Equations
What is Algorithm ???????
An algorithm, named for the ninth-century Persian mathematician
al-Khowarizm, is simply a set of rules for carrying out some
calculation, either by hand or, more usually, on a machine.
Definition :
It is a set of instructions of how to carry out a process. An
algorithm list the steps that must be followed to complete the
process and to reach the solution.
Different types of algorithms :
Probabilistic of Algorithm,
Approximate Algorithm,
Heuristics Algorithm
Step-1
Take a pan, and add water,
tea , and sugar to it
Step-2
Put the burner on low flame
Step-3
Heat the tea until it turns
a reddish brown colour
Step-4
Step-6
Increase the flame
Step-7
Stop the burner when the
milk rises to the top of
the pan.
Step-8
Filter all the solid out
Properties of the algorithm
1) Finiteness: - an algorithm terminates after a finite numbers of steps.
Properties of the algorithm
1) Finiteness: - an algorithm terminates after a finite numbers of steps.
Natural Lang
Psuedo Code
Flowchart
Mathematics for algorithm
Set :
Definition :
◦ Set is a collection of objects. These objects are called
elements of the set. So, A set is an unordered collection
of distinct element.
◦ All elements are enclosed within curly brackets ‘{‘ and
‘}’ and every element is separated by commas.
◦ If ‘a’ is an element of set A then we say that a€A and if
‘a’ is not an elements of A then we say that a € A.
◦ Normally set is denoted by capital letter. The set can be
represented using three methods.
1) Listing Method
2) Describing properties
3) Recursive Method
Cont . . .
1. Listing Method
The elements are listed in the set.
Ex. A set of elements which is less than 5
{0 , 1 , 2 , 3 , 4}
2. Describing Properties
The properties of elements of a set defined the set.
Ex. A set of vowels
A = { a , e , i , o , u}
3. Recursion method
The recursion occurs to define the elements of the set.
Ex. A = {x / x is square of n} where n<=10
A = {0 , 1 , 4 , 9 , 16, 25 , …….. 100}
Finite-Infinite Set
A set is finite if it contains a finite number of elements; otherwise, the set
is infinite.
Cardinality
If X is a finite set, |x| , the cardinality of X, denotes the number of
elements in X.
If X is infinite set, we may write |X| = .
The empty set, denoted O, is the unique set whose cardinality is 0.
Power Set
The power set is a set of all the subsets of its elements.
Ex. A= {1 , 2 , 3}
Q = { O , {1} , {2} , {3} , {1,2} , {1,3}, {2,3} , {1,2,3}}
X Y “ X is subset of Y ”
Each elements of X is belongs to Y.
X Y “ X is a proper subset of Y ”
Means that X Y and moreover that there is at
least one element in Y that does not belongs to X.
Equal Set
The two sets are said to be equal (A=B) if A B and
B A.
Operations on Sets
1) Union 2) Intersection 3) Difference 4) Complement
1) Union
AUB is a union operation – If A={1,2,3} , B={1,2,4}
then AUB = {1, 2, 3, 4}
2) Intersection
A∩B is intersection operation – If A={1,2,3} , B={2,3,4}
then A∩B = {2 , 3}
3) Difference
A-B is the difference operation – If A={1,2,3} ,B={2,3,4}
then A-B = {1} means elements which are in set A but not in set B
4) Complement of A
Complement of (A) = U – A where U is universal set
Ex. U={10,20,30,40,50} and A={10,20}
Complement(A) = {30 , 40 , 50}
Cartesian Product of Two Set
Ex.
A = {a , b} and B = {0 , 1 , 2}
A X B = {{a,0},{a,1},{a,2},{b,0},{b,1},{b,2}}
Explain Function & Relation with Example
Propositional calculation:
A Boolean (or propositional) variable may only take
one of this two values(true or false).
If p is a Boolean variable, we write “p is true” , or
simply “p” , to mean “p=true”
Let p and q be two Boolean variables.
conjunction p q or p and q ,
disjunction p q or p or q ,
negation p or not p,
if p then q p q
p q either both true or both false.
Interval :
An interval is a set of real numbers lying between
two bonds.
Let a and b be two real numbers such that a<=b.
Zero Vector :
If all the ui are zero i.e., ui = 0, then u is called the zero
vector.
Equal Vector :
Given vectors u and v are equal i.e., u = v, if they have
the same number of components and if corresponding
components are equal.
Addition of Two Vectors
If two vectors, u and v, have the number of components, their sum,
u + v, is the vector obtained by adding corresponding components from
u and v.
u + v = (u1, u2, . . . , un) + (v1, v2, . . . , vn)
= (u1 + v1 , u2 + v2 , . . . , un + vn)
The dot product or inner product of vectors u = (u1, u2, . . . , un) and
v = (v1, v2, . . . , vn) is denoted by u.v and defined by
u.v = u1v1 + u2v2 + . . . + unvn
A =
Note that the element aij, called the ij-entry, appear in the ith row
and the jth column.
A+B =
=
Scalar Multiplication
The product of a scalar k and a matrix A, written kA or Ak, is
the matrix obtained by multiplying each element of A by k.
kA = k
If K = 3
Properties of Matrix under Addition and
Multiplication
1. A+B=B+A
2. A+0 = 0 +A=A
3. A + (-A) = (-A) + A = 0
4. k(A + B) = kA + kB
5. (k + l)A = kA + lA
6. (kl)A = k(lA)
Matrix Multiplication
Suppose A and B are two matrices such that the number of
columns of A is equal to number of rows of B. Say matrix A is
an m×p matrix and matrix B is a p×n matrix. Then the product
of A and B is the m×n matrix whose ij-entry is obtained by
multiplying the elements of the ith row of a by the
corresponding elements of the jth column of B and then adding
them.
1. (AB)C = A(BC)
2. A(B+C) = AB + AC
3. (B+C)A = BA + CA
4. k (AB) = (k A)B = A(k B)
Transpose
The transpose of a matrix A is obtained by writing the row of A, in
order, as columns and denoted by AT.
For example if A =
then AT =
Square Matrix
If the number of rows and the number of columns of any
matrix are the same, we say matrix is a square matrix, i.e., a
square matrix has same number of rows and columns.
A square matrix with n rows and n columns is said to be
order n and is called an n-square matrix.
Unit Matrix
The n-square matrix with 1's along the main diagonal and
0's elsewhere is called the unit matrix and usually denoted
by I.
Determinants
To each n-square matrix A = (aij), we assign a
specific number called the determinants of A and
denoted as
|A| = del(A)
= a11a22 - a12a21
The determinant of order three is
Example :
5x + 10y = 15
3x + 2y = 5
Cont . .
Example
Gauss Elimination Method
GTU QUESTIONS