1 of 26

ALGORITHM

Keys Concepts # 1

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

2 of 26

Coding Concept

Sub - Concepts

Algorithm

  • Definition of algorithm
  • Characteristics of an algorithm
  • Examples of algorithm
  • Design algorithm for simplifying problems

Concept Overview

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

3 of 26

  • Define algorithm with examples.
  • Explain the characteristics of an algorithm.
  • Write an algorithm for a given problem.
  • Explain the benefits of using algorithms to solve a problem.

Objectives

Objectives

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

4 of 26

ALGORITHM

ACTIVITIES

  1. Understanding Algorithm
  2. Demo 1 - Brushing your teeth
  3. Activity 1 - Writing Algorithm
  4. Demo 2 - Adding two numbers
  5. Activity 2 - Multiplying two numbers
  6. Activity 3 - Area of circle
  7. Activity 4 - Perimeter of rectangle
  8. Activity 5 - Eligibility for voting
  9. Activity 6 - Even or odd Number
  10. Activity 7 - Check Your Understanding
  11. Activity 8 - Importance of learning algorithm
  12. Activity 9 - Practice Questions

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

5 of 26

Algorithm

An algorithm is a step-by-step set of instructions for performing a task.

Step

Algorithm

1

START

2

Read first number

3

Read second number

4

Add first and second number

5

Display the sum

6

STOP/End

Inputs

Process

Output

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

6 of 26

Algorithm (cont.)

For an algorithm, you need to have the following:

  1. Input
  1. Process
  1. Output

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

7 of 26

Demo 1 - Brushing Your Teeth

Step

Algorithm

1

START

2

Walk to a bathroom.

3

Put toothpaste on the toothbrush.

4

Brush your teeth.

5

Rinse your mouth and toothbrush.

6

Put the toothbrush away.

7

STOP/End

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

8 of 26

Activity 1 - Writing Algorithm

  1. Divide yourselves into four groups.
  2. Each group will receive a topic and in respective groups discuss the steps.
  3. Write an algorithm for the problem in your notebook.
  4. Then share the algorithm to the class.

Washing hands

G-4

Preparing suja

Crossing a road

1

Washing hands

2

C

4

Cooking ema-datshi

3

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

9 of 26

Activity 1 - Solution

Algorithm for Crossing a road

  1. Walk to an edge of a road.
  2. Look right and left for a vehicle.
  3. Wait if there is a vehicle.
  4. Cross the road once it is safe.
  5. Reach the other side.

Algorithm for Preparing suja

  1. Add suja tea leaves and water in a pot.
  2. Boil for 15 minutes.
  3. Takeout the tea leaves.
  4. Add salt and butter.
  5. Mix with a machine.
  6. Ready to drink.

1

2

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

10 of 26

Activity 1 - Solution (cont.)

Algorithm for Preparing ema-datshi

  1. Wash the chillies, onions and tomatoes.
  2. Chop and put in a pot.
  3. Add oil, salt and cheese.
  4. Cook for 20 minutes.
  5. Stir for few seconds.
  6. Ready to eat.

Algorithm for Washing hands

  1. Wet hands and apply soap.
  2. Rub the palms together.
  3. Rub the back of hands.
  4. Rub the back of the fingers.
  5. Rub and clean the thumbs.
  6. Rub and clean the tips of the fingers.
  7. Rinse the hands.

3

4

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

11 of 26

Importance of Algorithm

To provide a straightforward explanation of how it works without getting into too technical.

5

To find a solution for the problem.

1

To understand

the core idea behind a problem.

3

To understand the flow of the problem.

2

To break down a complex problem into smaller and more manageable steps.

4

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

12 of 26

Characteristics of Algorithm

Watch the video to understand the characteristics of algorithm

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

13 of 26

Characteristics of Algorithm

Characteristics

of

Algorithm

Unambiguous

Finiteness

Algorithm steps should be clear and straightforward.

Algorithm should terminate after certain number of steps.

Output

Algorithm should have have at least one output.

Feasibility

Algorithm should be feasible.

Independent

Algorithm must be applicable to any language.

Input

Algorithm should have 0 or more inputs.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

14 of 26

Demo 2 - Finding Average of Two Numbers

Write an algorithm to find the average of any two numbers entered by the user and display the result.

Step

Algorithm

1

START.

2

Read any two numbers(x and y).

3

Average = (x+y)/2.

4

Display Average.

5

STOP/End.

Solution

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

15 of 26

Activity 2 - Multiplying Two Numbers

Solution

Write an algorithm to multiply any two numbers and display the result.

Step

Algorithm

1

START.

2

Take input for x and y.

3

Multiply = x * y.

4

Display Multiply.

5

STOP.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

16 of 26

Activity 3 - Area of Circle

Solution

Write an algorithm in your notebook to find the area of a circle when a user enters a radius from the keyboard and display the area.

Step

Algorithm

1

START.

2

Read a radius of a circle (r).

3

area = 3.14*r*r.

4

Display area.

5

STOP.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

17 of 26

Activity 4 - Perimeter of Rectangle

Solution

Write an algorithm in your notebook to find the perimeter of a rectangle and display the perimeter.

Step

Algorithm

1

START.

2

Read a length and width (l, w).

3

perimeter = 2*(l+w) or perimeter = l+w+l+w.

4

Display perimeter.

5

STOP.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

18 of 26

Activity 5 - Eligibility for voting

Solution

Write an algorithm in your notebook to check whether a person is eligible to cast a vote using the following criteria:

  1. If the age is 18 and above, then display a message ‘Eligible to vote’
  2. Otherwise display a message, ‘Not eligible to vote.’

Step

Algorithm

1

START.

2

Read the age.

3

Check if age>= 18, then got to step 4

4

Display ‘Eligible to vote’.

5

Otherwise, display ‘Not eligible to vote’.

6

STOP.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

19 of 26

Activity 6 - Even or Odd number

Solution

Arrange the given algorithm in correct order to check whether the number is even or odd.

  1. R=num%2
  2. Display ‘Number is Even’
  3. START
  4. Display ‘Number is Odd’
  5. STOP
  6. If R is equal to zero
  7. Read the number(num)

Step

Algorithm

1

START.

2

Read the number(num).

3

R=num%2.

4

If R is equal to zero.

5

Display ‘Number is Even’.

6

Otherwise

7

Display ‘Number is Odd’.

8

STOP.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

20 of 26

Activity 7 - Check your understanding

Mention and explain the characteristics of an algorithm.

Unambiguous

Algorithm steps should be clear and straightforward.

1

Input

Algorithm may or may not take input.

2

Finiteness

Algorithm should terminate after certain number of steps.

3

Independent

Algorithm must be applicable to any language.

4

Feasibility

Algorithm should be feasible.

5

Output

Algorithm should have have at least one output.

6

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

21 of 26

Activity 8 - Importance of learning algorithm

List any three importance of learning algorithm.

To understand the core idea behind a problem.

To understand the flow of the problem.

To break down a complex problem.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

22 of 26

Practice 1 - Greatest Number

Solution

Write an algorithm to find the greatest of two numbers.

Step

Algorithm

1

START

2

Read any two numbers a, b

3

Check if a>b, then go to step 4

4

Display “a is greater than b”

5

Otherwise, Display “b is greater than a”

6

STOP

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

23 of 26

Practice 2 - Pass or Fail

Solution

Write an algorithm that prompts the user to input their exam marks and determines whether they have passed or failed. The pass mark is 40 out of 100.

Step

Algorithm

1

START

2

Enter a mark [m]

3

Check if m>=40, then go to step 4

4

Display ”Passed”

5

Otherwise, Display “Failed”

6

STOP

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

24 of 26

  • An algorithm is step-by-step solution for a specific problem.
  • In algorithm you need to have input, process and output.
  • Algorithm is used to understand the flow of the problem.
  • Algorithm helps to break down a complex problem into smaller and more manageable steps.

Key Points

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

25 of 26

Key Points (Cont.)

  • Characteristics of algorithms are:
    • Unambiguous : steps should be clear.
    • Inputs : it may or may not take input.
    • Output : should produce at least one output.
    • Finite : should have limited number of steps.
    • Feasibility : should be feasible.
    • Independent : must be applicable to any languages.

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD

26 of 26

བཀྲིན་ཆེ།

THANK YOU

January 2024

PYTHON

Key stage IV

Class IX

© ICT Curriculum, MoESD