Menu

Algorithm | Algorithm Design Techniques

  • Algorithm is a step by step sequence of instruction to solve a particular problem or task.
  • The algorithm can be defined as a well-defined sequence of instructions to solve a particular task.

Algorithm Design Techniques

  1. Start
  2. Input and output should be defined clearly.
  3. The algorithm should be effective to solve a particular task or problem
  4. An algorithm shouldn't include computer code in it

Algorithm explanation in Real Life

  • An algorithm can be compared to real life. Suppose You are going to shop for buying sweets. Here You will take an initiative to travel to the shop. That means you need a start here. Next, you will take your vehicle. Here checking the condition of the vehicle is ok or not. If yes, you will start your travel. Check your shop. Ask your product. If you got the product, you will return home.
  • In the above real-life example, your task is buying sweets. For buying the sweets, you have to take some steps. Actually here algorithm can be defined as these step by step actions or steps to complete your task.

write an algorithm for buying sweets

        Step1: Start
        Step2: Initiate to travel to shop
        Step3: Checking your condition to go to the shop. If yes go to step 4 else go to step 3
        Step4: Find the shop
        Step5: Buy the product
        Step6: Return to home
        Step7: Stop

  • Same as you can write an algorithm for a program on the computer. Before any programming, Just imagine what you are going to do. The algorithm can be defined as the imagination of steps for doing a particular task.
  • Consider you have to solve some of two numbers. Before you are going to programming, You should think about how you can solve this problem. 

Write an algorithm to find the sum of two numbers

       Step1: Start
       Step2: Declare the variables number1, number2, and sum
       Step3: Input the numbers number1, number2
       Step4: sum <- number1 + number2
       Step5: Print the value of the sum
       Step6: Stop

Examples of Algorithm

  1. Write an algorithm to find the largest of two numbers
  2. Write an algorithm to find the largest of three numbers
  3. Write an algorithm to find factorial of a number of an entered number.
  4. Write an algorithm to find Fibonacci series up to a 100.