Ada Unit 1 Handbook
Ada Unit 1 Handbook
Unit-1
1.1. Algorithm
An algorithm is any well-defined computational procedure that takes some values or set
of values as input and produces some values or set of values as output.
An algorithm is a sequence of computational steps that transform the input into the
output.
An algorithm is a set of rules for carrying out calculation either by hand or on a machine.
2. Output: By using inputs which are externally supplied the algorithm produces at
least one quantity as output.
3. Definiteness: The instructions used in the algorithm specify one or more operations.
These operations must be clear and unambiguous. This implies that each of these
operations must be definite; clearly specifying what is to be done.
4. Finiteness: Algorithm must terminate after some finite number of steps for all cases.
5. Effectiveness: The instructions which are used to accomplish the task must be basic
i.e., the human being can trace the instructions by using paper and pencil in every
way.
2. Mathematics for Algorithmic Set
2.1. Set
The number of elements in a set is called cardinality or size of the set, denoted |S| or
sometimes n(S).
The two sets have same cardinality if their elements can be put into a one-to-one
correspondence. It is easy to see that the cardinality of an empty set is zero i.e., |ø|.
2.3. Multiset
If we do want to take the number of occurrences of members into account, we call the
group a multiset.
For example, {7} and {7, 7} are identical as set but {7} and {7, 7} are different as
multiset.
A set contains infinite elements. For example, set of negative integers, set of integers,
etc. …
2.6. Subset
For two sets A and B, we say that A is a subset of B, written A B, if every member of set
A is also a member of set B.
Formally, A⊆B if x ϵ A implies x ϵ B
2.7. Proper Subset
Set A is a proper subset of B, written A⊂B, if A is a subset of B and not equal to B. That
is, a set A is proper subset of B if A⊆B but A≠B.
2.8. Equal Sets
The sets A and B are equal, written A = B, if each is a subset of the other.
Let A be the set. The power of A, written P(A) or 2A, is the set of all subsets of A. That is,
P (A) = {B: B⊆A}.
The union of A and B, written A∪B, is the set we get by combining all elements in A and
B into a single set.
The intersection of set A and B, written A ∩ B, is the set of elements that are both in A
and in B. That is, A ∩ B = {x: x ϵ A and x ϵ B}.
All set under consideration are subset of some large set U called universal set.
Given a universal set U, the complement of A, written A', is the set of all elements under
consideration that are not in A.
2.16. Sequences
A sequence of objects is a list of objects in some order. For example, the sequence 7, 21,
57 would be written as (7, 21, 57). In a set the order does not matter but in a sequence it
does.
Repetition is not permitted in a set but repetition is permitted in a sequence. So, (7, 7, 21,
57) is different from {7, 21, 57}.
3.1. Relation
Let X and Y be two sets. Any subset ρ of their Cartesian product X x Y is a relation.
Relationship between two sets of numbers is known as function. Function is special kind
of relation.
But note that function maps values to one value only. Two values in one set could map to one
value but one value must never map to two values.
3.2. Function
The set X is called domain of function, set Y is its image and the set f(D)={f(x)|xЄD} is
its range.
f(x) = x3
f (-1) = (-1)3 = -1
f (2) = (2)3 = 8
f (3) = (3)3 = 27
In general, we can say that a relation is any subset of the Cartesian product of its domain
and co-domain.
The function maps only one value from domain to its co domain while relation maps one
value from domain to more than one values of its co domain.
So that by using this concept we can say all functions are considered as relation also but
not vice versa.
Different relations can observe some special properties namely reflexive, symmetric,
transitive and Anti symmetric.
Reflexive:
When for all values of x and y, x R y → y R x is true. Then we can say that relation
R is symmetric. Equality (=) relation is also symmetric.
Transitive:
When for all values of x, y and z, x R y and y R z then we can say that x R z, which
is known as transitive property of the relation.
If x>y and y>z then we can say that x>z i.e. x is greater than y and y is greater than z
then x is also greater than z.
Anti-symmetric:
When for all values of x and y if x R y and y R x implies x=y then relation R is Anti
- symmetric.
Anti-symmetric property and symmetric properties are lookalike same but they are
different.
E.g., consider the relation greater than or equal to ≥ if x ≥ y and y ≥ x then we can
say that y = x.
A relation is Anti-symmetric if and only if x X and (x, x) R.
Equivalence Relation:
The relation is equivalent only when it satisfies all following property i.e. relation
must be reflexive, symmetric and transitive then it is called Equivalence Relation.
E.g., Equality ‘=’ relation is equivalence relation because equality proves above
condition i.e., it is reflexive, symmetric and transitive.
Reflexive: x=x is true for all values of x. so we can say that’=’ is reflexive.
Symmetric: x=y and y=x is true for all values of x and y then we can say that
‘=’ is symmetric.
Transitive: if x=y and y=z is true for all values then we can say that x=z. thus’
=’ is transitive.
Where ui are called the components of u. If all the ui are zero i.e., ui = 0, then u is called
the zero 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.
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.
The product of a scalar k and a vector u i.e., ku, is the vector obtained by multiplying
each component of u by k:
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|| =
𝑢 + 𝑢 +. . . . . . +𝑢
4.4. Matrices
Matrix, A, means a rectangular array of numbers
The m horizontal n-tuples are called the rows of A, and the n vertical m-tuples, its
columns. Note that the element aij, called the ij-entry, appear in the ith row and the jth
column.
A matrix whose entries are all zero is called a zero matrix and denoted by 0.
Let A and B be two matrices of the same size. The sum of A and B is written as A + B and
obtained by adding corresponding elements from A and B.
Let A, B, and C is matrices of same size and let k and I two scalars. Then
i. (A + B) + C = A + (B + C)
ii. A+B =B +A
v. k(A + B) = kA + kB
vi. (k + I)A = kA + I A
viii. IA=A
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 j th column of B and
then adding them.
It is important to note that if the number of columns of A is not equal to the number of
rows of B, then the product AB is not defined.
i. (AB)C = A(BC)
ii. A(B+C) = AB + AC
iii. (B+C) A = BA + CA
4.11. Transpose
The transpose of a matrix A is obtained by writing the row of A, in order, as columns and
denoted by AT. In other words, if A - (Aij), then B = (bij) is the transpose of A if bij - aji
for all i and j.
For example, if
A= then AT =
If the number of rows and the number of columns of any matrix are 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.
The main diagonal, or simply diagonal, of an n-square matrix A = (aij) consists of the
elements a(11), a(22), a(33) . . . a(mn).
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.
The unit matrix plays the same role in matrix multiplication as the number 1 does in the
usual multiplication of numbers.
5.1. Inequalities
The term inequality is applied to any statement involving one of the symbols <, >, ≤, ≥.
i. x≥1
ii. x + y + 2z > 16
iii. p2 + q2 ≤1/2
iv. a2 + ab > 1
4. If a ≤ b and b ≤ c, then a ≤ c.
For example, 1 is a solution of 2x + 3 ≤ 7 since 2(1) + 3 = 5 and 5 is less than and equal
to 7.
A solution of an inequality is said to satisfy the inequality. For example, (2, 1) is satisfy x
– y ≤ 5.
One Unknown
A linear equation in one unknown can always be stated into the standard form
ax = b
Where x is an unknown and a and b are constants. If a is not equal to zero, this
equation has a unique solution
x = b/a
Two Unknowns
A linear equation in two unknown, x and y, can be put into the form
ax + by = c
Where x and y are two unknowns and a, b, c are real numbers. Also, we assume that a
and b are no zero.
A solution of the equation consists of a pair of number, u = (k1, k2), which satisfies the
equation ax + by = c.
Mathematically speaking, a solution consists of u = (k1, k2) such that ak1 + bk2 = c.
Solution of the equation can be found by assigning arbitrary values to x and solving for y
or assigning arbitrary values to y and solving for x.
a1 x + b1 x = c 1
a2 x + b2 x = c 2
Where a1, a2, b1, b2 are not zero. A pair of numbers which satisfies both equations is
called a simultaneous solution of the given equations or a solution of the system of
equations.
1. If the system has exactly one solution, the graph of the linear equations intersects in
one point.
2. If the system has no solutions, the graphs of the linear equations are parallel.
3. If the system has an infinite number of solutions, the graphs of the linear equations
coincide.
The special cases (2) and (3) can only occur when the coefficient of x and y in the two
linear equations are proportional.
OR => a1b2 - a2b1 = 0 => =0
The solution to the following system can be obtained by the elimination process,
whereby reduce the system to a single equation in only one unknown.
a1x + b1x = c1
a2x + b2x = c2