"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Algorithm
1. Algorithms
• USING ALGORITHMS TO SOLVE PROBLEMS
• What is an Algorithm?
• An algorithm is a step-by-step procedure to
solve a given problem
2. Steps in algorithm writing:
• Ø Identify all the inputs and outputs required
for solving a problem.
• Ø Identify additional data and constants
needed.
• Ø Computation steps
• Ø Print / Display all the required results.
3. DIFFERENT PATTERNS IN ALGORITHMS
• There are mainly three different patterns of
algorithms. They are as listed below-
• Sequential – The steps represent sequence of
occurrence of processing.
• Conditional – Based on one or more conditions
the instructions are divided
• Iterational – Same set of instructions are
repeated more than once until an end condition.
These are also called Repetitive patterns
4. EXAMPLES
• On Sequential Patterns
• Write an algorithm to find the sum of any two
numbers.
• Write an algorithm to find the average of
three numbers.
• Write an algorithm to find the volume of a
cylinder.
5. On Sequential Patterns
• Write an algorithm to find the area and
perimeter of a square.
• Write an algorithm to convert Celsius into
Fahrenheit.
6. On Conditional Patterns
• Write an algorithm to find biggest of two
numbers.
• Write an algorithm to check whether a given
number is +ve, -ve or a zero.
• Write an algorithm to check whether a given
number is even or odd.
• Write an algorithm to find a person’s eligibility
for voting, based on his/her age.
7. On Iterational Patterns
• Write an algorithm to print a number (5) 10
times.
• Write an algorithm to print all the odd
numbers between 1 and 10.
• Write an algorithm to print all the even
numbers between 1 and 10.