0% found this document useful (0 votes)
30 views18 pages

SOU - Lecture Handout - ADA - Unit-1

The document discusses basics of algorithms including their definition, properties, time complexity and space complexity. It provides examples to explain concepts like time complexity calculation and order of growth. Space complexity and auxiliary space are also explained. Key aspects covered are input, output, definiteness, finiteness and effectiveness as properties of algorithms.

Uploaded by

prince2412001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views18 pages

SOU - Lecture Handout - ADA - Unit-1

The document discusses basics of algorithms including their definition, properties, time complexity and space complexity. It provides examples to explain concepts like time complexity calculation and order of growth. Space complexity and auxiliary space are also explained. Key aspects covered are input, output, definiteness, finiteness and effectiveness as properties of algorithms.

Uploaded by

prince2412001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

1010043316

(ANALYSIS & DESIGN OF


ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

CHAPTER 1 BASICS OF ALGORTIHM & MATHEMATICS


1. Algorithm and Properties of Algorithm

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.

 An algorithm is an abstraction of a program to be executed on a physical machine (model


of Computation).

1.2. Properties of Algorithm

 All the algorithms should satisfy following five properties,

1. Input: There is zero or more quantities supplied as input to the algorithm.

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. Time and Space Complexity

Generally, there is always more than one way to solve a problem in computer science with
different algorithms. Therefore, it is highly required to use a method to compare the solutions
in order to judge which one is more optimal. The method must be:

DEPARTMENT OF COMPUTER ENGINEERING Page | 1


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 Independent of the machine and its configuration, on which the algorithm is running
on.
 Shows a direct correlation with the number of inputs.
 Can distinguish two algorithms clearly without ambiguity.

There are two such methods used, time complexity and space complexity which are discussed
below:

Time Complexity: The time complexity of an algorithm quantifies the amount of time taken
by an algorithm to run as a function of the length of the input. Note that the time to run is a
function of the length of the input and not the actual execution time of the machine on which
the algorithm is running on.

Definition–

The valid algorithm takes a finite amount of time for execution. The time required by the
algorithm to solve given problem is called time complexity of the algorithm. Time complexity
is very useful measure in algorithm analysis.

It is the time needed for the completion of an algorithm. To estimate the time complexity, we
need to consider the cost of each fundamental instruction and the number of times the
instruction is executed.

Example 1: Addition of two scalar variables.

Algorithm ADD SCALAR (A, B)

//Description: Perform arithmetic addition of two numbers

//Input: Two scalar variables A and B

//Output: variable C, which holds the addition of A and B

C <- A + B

return C

The addition of two scalar numbers requires one addition operation. the time complexity of this
algorithm is constant, so T(n) = O (1) .
DEPARTMENT OF COMPUTER ENGINEERING Page | 2
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

In order to calculate time complexity on an algorithm, it is assumed that a constant time c is


taken to execute one operation, and then the total operations for an input length on N are
calculated. Consider an example to understand the process of calculation: Suppose a problem
is to find whether a pair (X, Y) exists in an array, A of N elements whose sum is Z. The simplest
idea is to consider every pair and check if it satisfies the given condition or not.

The pseudo-code is as follows:

int a[n];

for(int i = 0;i < n;i++)

cin >> a[i]

for(int i = 0;i < n;i++)

for(int j = 0;j < n;j++)

if(i!=j && a[i]+a[j] == z)

return true

return false

Assuming that each of the operations in the computer takes approximately constant time, let it
be c. The number of lines of code executed actually depends on the value of Z. During analyses
of the algorithm, mostly the worst-case scenario is considered, i.e., when there is no pair of
elements with sum equals Z. In the worst case,

 N*c operations are required for input.


 The outer loop i loop runs N times.
 For each i, the inner loop j loop runs N times.

So total execution time is N*c + N*N*c + c. Now ignore the lower order terms since the lower
order terms are relatively insignificant for large input, therefore only the highest order term is
taken (without constant) which is N*N in this case. Different notations are used to describe the
limiting behavior of a function, but since the worst case is taken so Big-O notation will be used
to represent the time complexity.

DEPARTMENT OF COMPUTER ENGINEERING Page | 3


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

Hence, the time complexity is O (N2) for the above algorithm. Note that the time complexity
is solely based on the number of elements in array A i.e the input length, so if the length of the
array will increase the time of execution will also increase.

Order of growth is how the time of execution depends on the length of the input. In the above
example, it is clearly evident that the time of execution quadratically depends on the length of
the array. Order of growth will help to compute the running time with ease.

Space Complexity:

Definition – Problem-solving using computer requires memory to hold temporary data or final
result while the program is in execution. The amount of memory required by the algorithm to
solve given problem is called space complexity of the algorithm.

The space complexity of an algorithm quantifies the amount of space taken by an algorithm to
run as a function of the length of the input. Consider an example: Suppose a problem to find
the frequency of array elements.

It is the amount of memory needed for the completion of an algorithm.

To estimate the memory requirement, we need to focus on two parts:

1) A fixed part: It is independent of the input size. It includes memory for instructions
(code), constants, variables, etc.
2) A variable part: It is dependent on the input size. It includes memory for recursion
stack, referenced variables, etc.

Example: Addition of two scalar variables

Algorithm ADD SCALAR (A, B)

//Description: Perform arithmetic addition of two numbers

//Input: Two scalar variables A and B

//Output: variable C, which holds the addition of A and B

C <— A+B

DEPARTMENT OF COMPUTER ENGINEERING Page | 4


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

return C

The addition of two scalar numbers requires one extra memory location to hold the result. Thus
the space complexity of this algorithm is constant, hence S(n) = O (1).

The pseudo-code is as follows:

int freq[n];

int a[n];

for (int i = 0; i<n; i++)

cin>>a[i];

freq[a[i]]++;

Here two arrays of length N, and variable i are used in the algorithm so, the total space used is
N * c + N * c + 1 * c = 2N * c + c, where c is a unit space taken. For many inputs, constant c
is insignificant, and it can be said that the space complexity is O(N).

There is also auxiliary space, which is different from space complexity. The main difference is
where space complexity quantifies the total space used by the algorithm, auxiliary space
quantifies the extra space that is used in the algorithm apart from the given input. In the above
example, the auxiliary space is the space used by the freq [] array because that is not part of the
given input. So total auxiliary space is N * c + c which is O(N) only.

3. Detailed analysis of Algorithm

In computer science, the analysis of algorithms is the process of finding the computational
complexity of algorithms—the amount of time, storage, or other resources needed to execute
them. Usually, this involves determining a function that relates the size of an algorithm's input
to the number of steps it takes (its time complexity) or the number of storage locations it uses
(its space complexity). An algorithm is said to be efficient when this function's values are small,
or grow slowly compared to a growth in the size of the input. Different inputs of the same size
DEPARTMENT OF COMPUTER ENGINEERING Page | 5
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

may cause the algorithm to have different behavior, so best, worst and average case
descriptions might all be of practical interest. When not otherwise specified, the function
describing the performance of an algorithm is usually an upper bound, determined from the
worst case inputs to the algorithm.

The term "analysis of algorithms" was coined by Donald Knuth Algorithm analysis is an
important part of a broader computational complexity theory, which provides theoretical
estimates for the resources needed by any algorithm which solves a given computational
problem. These estimates provide an insight into reasonable directions of search for efficient
algorithms.

In theoretical analysis of algorithms, it is common to estimate their complexity in the


asymptotic sense, i.e., to estimate the complexity function for arbitrarily large input. Big O
notation, Big-omega notation and Big-theta notation are used to this end. For instance, binary
search is said to run in a number of steps proportional to the logarithm of the size n of the sorted
list being searched, or in O (log n), colloquially "in logarithmic time". Usually asymptotic
estimates are used because different implementations of the same algorithm may differ in
efficiency. However, the efficiencies of any two "reasonable" implementations of a given
algorithm are related by a constant multiplicative factor called a hidden constant.

Exact (not asymptotic) measures of efficiency can sometimes be computed but they usually
require certain assumptions concerning the particular implementation of the algorithm, called
model of computation. A model of computation may be defined in terms of an abstract
computer, e.g. Turing machine, and/or by postulating that certain operations are executed in
unit time. For example, if the sorted list to which we apply binary search has n elements, and
we can guarantee that each lookup of an element in the list can be done in unit time, then at
most log2(n) + 1 time units are needed to return an answer.

4. Mathematics for Algorithmic Set

4.1. Set

 Unordered collection of distinct elements. Can be represented either by property or by


value.

DEPARTMENT OF COMPUTER ENGINEERING Page | 6


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

4.2. Set Cardinality

 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., |ø|.

4.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.

4.4. Infinite Set

 A set contains infinite elements. For example, set of negative integers, set of integers, etc

4.5. Empty Set

 Set contain no member, denoted as { } or ø.

4.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
4.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.
4.8. Equal Sets

 The sets A and B are equal, written A = B, if each is a subset of the other.

 Let A and B be sets. A = B if A⊆ B and B⊆ A.

DEPARTMENT OF COMPUTER ENGINEERING Page | 7


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

4.9. Power Set

 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}.

 For example, consider A= {0, 1}.

 The power set of A is {{}, {0}, {1}, {0, 1}}.

4.10. Union of sets

 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.

 That is A∪B = {x: x ϵ A or x ϵ B}.

4.11. Disjoint sets

 Let A and B be sets. A and B are disjoint if A ∩ B = Φ.


4.12. Intersection sets

 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}.

4.13. Difference of Sets

 Let A and B be sets. The difference of A and B is A - B = {x : x ϵ A and x ∉ B}.


 For example, let A = {1, 2, 3} and B = {2, 4, 6, 8}. The set difference A-B={1,3} while
B-A={4, 6, 8}.

4.14. Complement of a set

 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.

 Formally, let A be a subset of universal set U.

 The complement of A in U is A' = A - U OR A' = {x: x ϵ U and x ∉ A}.

DEPARTMENT OF COMPUTER ENGINEERING Page | 8


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

4.15. Symmetric difference

 Let A and B be sets. The symmetric difference of A and B is,

A⊕B = { x : x ϵ A or x ϵ B but not in both}


 As an example, consider the following two sets A = {1, 2, 3} and B = {2, 4, 6, 8}. The
symmetric difference, A⊕B = {1, 3, 4, 6, 8}.

4.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}.

5. Functions & Relations

5.1. Relation

 Let X and Y be two sets. Any subset ρ of their Cartesian product X x Y is a relation.

 When x Є X and y Є Y, we say that x is in relation with y according to ρ denoted as x ρ y


if and only if (x, y) Є ρ.

 Relationship between two sets of numbers is known as function. Function is special kind
of relation.

 A number in one set is mapped to number in another set by the function.

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.

5.2. Function

 Consider any relation f between x and y.

 The relation is called a function if for each x Є X, there exists one and only one y Є Y such
that (x, y) Є f.
DEPARTMENT OF COMPUTER ENGINEERING Page | 9
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 This is denoted as f : x → y, which is read as f is a function from x to y denoted as f(x).

 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.

 For example, if we write function as follows,

f(x) = x3

 Then we can say that f(x) equals to x cube.

 For following values it gives result as,

f(-1) = (-1)3 = -1

f(2) = (2)3 = 8

f(3) = (3)3 = 27

f(5) = (5)3 = 125

This function f(x) maps number to their cube.

 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.

5.3. Properties of the Relation

 Different relations can observe some special properties namely reflexive, symmetric ,
transitive and Anti symmetric.

 Reflexive:

 When for all values x: x R x is true then relation R is said to be reflexive.

 E.g. the equality (=) relation is reflexive.


DEPARTMENT OF COMPUTER ENGINEERING Page | 10
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 Symmetric:

 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.

 E.g. the relation grater then > is transitive 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:

 Equivalence Relation plays an important role in discrete mathematics.

 Equivalent relation declares or shows some kind of equality or say equivalence.

 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.

DEPARTMENT OF COMPUTER ENGINEERING Page | 11


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 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.

6. Vectors and Matrices

 A vector, u, means a list (or n-tuple) of numbers:

 u = (u1, u2, . . . , un)

 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.

6.1. 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)

6.2. Multiplication of a vector by a Scalar

 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:

ku = k(u1, u2, . . . , un) = ku1, ku2, . . . , kun

 It is not difficult to see k(u + v) = ku + kv where k is a scalar and u and v are vectors

6.3. Dot Product and Norm

 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

DEPARTMENT OF COMPUTER ENGINEERING Page | 12


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

The norm or length of a vector, u, is denoted by ||u|| and defined by

√𝑢. 𝑢
||u|| =
√𝑢12 + 𝑢22 +. . . . . . +𝑢𝑛2

6.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.

6.5. Column Vector

 A matrix with only one column is called a column vector.

6.6. Zero Matrix

 A matrix whose entries are all zero is called a zero matrix and denoted by 0.

6.7. Matrix Addition

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.

DEPARTMENT OF COMPUTER ENGINEERING Page | 13


*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

6.8. Properties of Matrix under Addition and Multiplication

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

iii. A+0= 0+A= A

iv. A + (-A) = (-A) + A = 0

v. k (A + B) = kA + kB

vi. (k + I) A = kA + I A

vii. (k I) A = k(I A)

viii. IA=A

6.9. 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.

 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.

6.10. Properties of Matrix Multiplication

Let A, B, and C be matrices and let k be a scalar. Then

i. (AB)C = A(BC)

ii. A(B+C) = AB + AC

iii. (B+C) A = BA + CA

iv. k(AB) = (kB)B = A(kB)


DEPARTMENT OF COMPUTER ENGINEERING Page | 14
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

6.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.

 It is not hard to see that if A is an m×n matrix, then AT is an n×m matrix.

For example, if

A= then AT =

6.12. Square Matrix

 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).

6.13. 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.

 The unit matrix plays the same role in matrix multiplication as the number 1 does in the
usual multiplication of numbers.

A I = I A = A for any square matrix A.

7. Linear Inequalities and Linear Equations.

7.1. Inequalities

The term inequality is applied to any statement involving one of the symbols <, >, ≤, ≥.

Examples of inequalities are:


DEPARTMENT OF COMPUTER ENGINEERING Page | 15
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

i. x≥1

ii. x + y + 2z > 16

iii. p2 + q2 ≤1/2

iv. a2 + ab > 1

7.2. Fundamental Properties of Inequalities

1. If a≤b and c is any real number, then a + c≤b + c.

For example, -3≤-1 implies -3+4≤-1 + 4.

2. If a≤b and c is positive, then ac≤bc.

For example, 2≤3 implies 2(4) ≤3(4).

3. If a≤b and c is negative, then ac≥bc.

For example, 3≤9 implies 3(-2) ≥9(-2).

4. If a≤b and b≤c, then a≤ c.

For example, -1/2≤2 and 2≤8/3 imply -1/2≤8/3.

7.3. Solution of Inequality

 By solution of the one variable inequality 2x + 3≤7 we mean any number which substituted
for x yields a true statement.

 For example, 1 is a solution of 2x + 3≤7 since 2(1) + 3 = 5 and 5 is less than and equal to
7.

 By a solution of the two variable inequality x - y≤5 we mean any ordered pair of numbers
which when substituted for x and y, respectively, yields a true statement.

 For example, (2, 1) is a solution of x - y≤5 because 2-1 = 1 and 1≤5.

 By a solution of the three variable inequalities 2x - y + z≥3 we means an ordered triple of


number which when substituted for x, y and z respectively, yields a true statement.

 For example, (2, 0, 1) is a solution of 2x - y + z≤3.


DEPARTMENT OF COMPUTER ENGINEERING Page | 16
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 A solution of an inequality is said to satisfy the inequality. For example, (2, 1) is satisfy x
- y≤5.

7.4. Linear Equations

 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.

7.5. Solution of Linear Equation

 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.

7.6. Two Equations in the Two Unknowns

 A system of two linear equations in the two unknowns x and y is

 a1 x + b1 x = c1

 a2 x + b2 x = c2
DEPARTMENT OF COMPUTER ENGINEERING Page | 17
*Proprietary material of SILVER OAK UNIVERSITY
1010043316
(ANALYSIS & DESIGN OF
ALGORTIHM)
LECTURE COMPANION SEMESTER: 5 PREPARED BY: PARTH S WADHWA

 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.

 Geometrically, there are three cases of a simultaneous solution

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 system has no solution when

 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

DEPARTMENT OF COMPUTER ENGINEERING Page | 18


*Proprietary material of SILVER OAK UNIVERSITY

You might also like