Algorithmic Thinking
Logic alone is not enough…
We need something that can integrate all these
rules and execute actions based on the
outcomes of evaluating them.
Algorithm:
a sequence of clearly defined steps that
describe a process to follow a
finite set of unambiguous instructions with
clear start and end points.
Real-life analogy:
Following a recipe while cooking
Properties of algorithms
Collection of individual steps
Definiteness
Sequential
Which do you think is a better algorithm?
(a) Take a left, then take a right, go down the stairs, on
your right enter the kitchen, pick a cup and pour some
hot water and add some hot chocolate….
(b) Please make me a hot chocolate.
Some examples of algorithms
Making a Cup of Tea Question: Can
• Step 1: Boil water. you achieve the
• Step 2: Place a teabag in a cup. same outcome by
• Step 3: interchanging a
Pour the boiling water into the cup.
few steps?
• Step 4: Let the tea steep for a few minutes.
• Step 5: Remove the teabag.
• Step 6: Add sugar and/or milk if desired.
• Step 7: Stir the tea.
• Step 8: Serve and enjoy.
TRY SOME EXAMPLES ON YOUR
OWN..
Calculate the area of a circle
Given the marks of 5 subjects,
calculate the percentage marks of a
student
Find if a student has passed or failed in
an exam considering passing
percentage as 50
Find the sum of digits of a three digit
number and display the sum
SAMPLE SOLUTIONS FOR
ALGORITHMS
Calculate the area of a circle
1. Input the radius of a circle
2. Calculate area by multiplying pi and radius
squared
3. Print area
SAMPLE SOLUTIONS FOR
ALGORITHMS
Given the marks of 5 subjects,
calculate the percentage marks of a
student
1. Input marks of 5 subjects of a student
each out of 50
2. Add the marks
3. Divide marks by 250 and multiply the
result by 100
4. Print the final percentage scored
SAMPLE SOLUTIONS FOR
ALGORITHMS
Find if a student has passed or failed in an
exam considering passing percentage as 50
1. Input marks of 5 subjects of a student each
out of 50
2. Add the marks
3. Divide marks by 250 and multiply the result
by 100
4. Check if the percentage calculated is less
than 50
5. If yes, print “Fail”
6. Else Print ”pass”
SAMPLE SOLUTIONS FOR
ALGORITHMS
Findthe sum of digits of a three digit number and
display the sum
Input the three-digit number from the user.
Extract the hundreds digit by performing integer division of the
number by 100.
Extract the remainder of the number when divided by 100
Extract the tens digit by Dividing the remainder by 10.
Extract the units digit by getting the remainder when the number
is divided by 10.
Add the extracted hundreds, tens, and units digits.
Display the result
PSEUDOCODE
Pseudocode is a more formalized, human-readable
description of the steps in an algorithm.
It uses a structured format, combining natural
language with elements of programming syntax,
to describe how an algorithm should be
implemented.
It bridges the gap between algorithm and actual
code.
It resembles programming logic but doesn’t
adhere to the strict syntax of a specific
PSEUDOCODE EXAMPLE
Calculate the area of a circle
Algorithm
1. START 1. Input the radius of a
circle
2. Input the radius of the circle
2. Calculate area by
3. Set Pi = 3.14159 multiplying pi and radius
4. area = Pi * radius * radius squared
Notation Meaning
5. Display the area of the circle
3. Print area
+ Addition
6. END - Subtraction
* Multiplication
/ Division
% Modulus
(Remainder)
PSEUDOCODE EXAMPLE
Giventhe marks of 5 subjects, calculate the
percentage marks of a student
1. START
2. Input marks for 5 subjects subject1_marks, subject2_marks,…
3. total_marks = subject1_marks + subject2_marks +
subject3_marks + subject4_marks + subject5_marks
4. max_marks = 250
5. percentage = (total_marks / max_total_marks) * 100
6. Display percentage
7. END
PSEUDOCODE EXAMPLE
Find
if a student has passed or failed in an exam
considering passing percentage as 50
1. START
2. Input marks for 5 subjects subject1_marks, subject2_marks,…
3. total_marks = subject1_marks + subject2_marks + subject3_marks +
subject4_marks + subject5_marks
4. max_marks = 250
5. percentage = (total_marks / max_total_marks) * 100
6. If percentage >= 50
Print “Pass”
7. Else
Print “Fail”
8. END
PSEUDOCODE EXAMPLE
Findthe sum of digits of a three digit number and
display the sum
1. START
2. Input a three digit number n
3. D1 = n/100
4. N = n%10
5. D2 = n/10
6. D3 = n%10
7. Sum = D1 + D2 + D3
8. Print Sum
9. END