Chapter 1 Algorithm and Complexity Lesson 1
Chapter 1 Algorithm and Complexity Lesson 1
and
Complexity
Double Tap to Add Subtitle
PAGE 1
Lesson 1: Intro to Algorithm and Complexity
Lesson 2
Course Lesson 3
Outline
Lesson 4
Lesson 5
PAGE 2
Objective
PAGE 3
Introduction
▪ What is an Algorithm? Algorithm Basics
▪ The word Algorithm means “a process or set of rules to be followed in calculations or other problem-
solving operations”. Therefore Algorithm refers to a set of rules/instructions that step-by-step define
how a work is to be executed to get the expected results.
▪ It can be understood by taking an example of cooking a new recipe. To cook a new recipe, one reads
the instructions and steps and executes them one by one, in the given sequence. The result thus
obtained is the new dish cooked perfectly. Similarly, algorithms help to do a task in programming to get
the expected output.
Introduction PAGE 4
Second Skill Third Skill Conclusion
Introduction
▪ What is an Algorithm? Algorithm Basics
Introduction PAGE 5
Second Skill Third Skill Conclusion
What are the Characteristics of an Algorithm?
An algorithm is a finite set of instructions that if followed, accomplishes a particular task. In addition, all
algorithms must satisfy following criteria (characteristics)
- Zero or more quantities - At least one quantity is Each instruction is clear &
are externally supplied. produced. unambiguous,
- Well-Defined Inputs If an - Well-Defined Outputs Clear and Unambiguous: The
algorithm says to take The algorithm must clearly algorithm should be clear and
define what output will be unambiguous. Each of its
inputs, it should be well steps should be clear in all
yielded and it should be
defined inputs aspects and must lead to only
well-defined as well. one meaning.
Finiteness Effectiveness
For all input cases it terminates Every instruction must be very basic so that
after finite number of steps, The it can be carried out, in principle, by a
person using only pencil and paper
algorithm must be finite, i.e. it (Feasible Instructions)
should not end up in infinite
Language Independent
loops or similar.
Feasible
Advantages of Algorithms
- It is easy to understand.
- The algorithm is a step-wise representation of a solution to a given
problem.
- In Algorithm the problem is broken down into smaller pieces or steps
hence, it is easier for the programmer to convert it into an actual
program.
Characteristic of Algorithm
PAGE 8
Introduction And its Advantage Third Skill Conclusion
Advantages and Disadvantage of Algorithms
Disadvantages of Algorithms
Characteristic of Algorithm
PAGE 9
Introduction And its Advantage Third Skill Conclusion
How to Design an Algorithm?
Then the algorithm is written with the help of the above parameters
such that it solves the problem.
Consider the example to add three numbers and print the sum.
Consider the example to add three numbers and print the sum.
1. START
2. Declare 3 integer variables num1, num2, and num3.
3. Take the three numbers, to be added, as inputs in variables num1, num2, and
num3 respectively.
4. Declare an integer variable sum to store the resultant sum of the 3 numbers.
5. Add the 3 numbers and store the result in the variable sum.
6. Print the value of variable sum
7. END
int main()
{
// Variables to take the input of
// the 3 numbers
int num1, num2, num3;
return 0;
}
// This code is contributed by shivanisinghss2110
Conclusion PAGE 16
First Skill Second Skill Third Skill
Lesson Following the Specification and Pre-requisite Create a ALGORITHIM
that using the steps presented here
Activity
Conclusion PAGE 17
First Skill Second Skill Third Skill
Lesson 1: Intro to Algorithm and Complexity
Course Lesson 3
Outline
Lesson 4
Lesson 5
PAGE 18