What is Algorithm? Characteristics of an algorithm, Advantage and Disadvantage of the Algorithm, Some Example of the Algorithm | C-Language || Edu Verse By Pratik | Code.WithPratik

Algorithm

What is Algorithm?

An algorithm is a step-by-step procedure or set of rules designed to perform a specific task or solve a particular problem. It is a sequence of instructions that are followed to achieve a desired outcome. Algorithms are fundamental to computer science and programming, as they provide a clear and efficient way to process data and perform computations.



Characteristics of an Algorithm

Algorithms have several key characteristics that define their structure and ensure they function correctly and efficiently. Here are the main characteristics of an algorithm:

1. Clear and Unambiguous:

Algorithm should be clear and unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning.

2. Well-Defined Inputs:

If an algorithm says to take inputs, it should be well-defined inputs.

3.Well-Defined Outputs:

If an algorithm says to take inputs, it should be well-defined inputs.

4.Finite-ness:

The algorithm must be finite, i.e., it should not end up in an infinite loops or similar.

5. Feasible:

The algorithm must be simple, generic and practical, such that it can be executed upon with the available resources. it must not contain some future technology, or anything.

6. Language Independent:

The algorithms designed must be language-independent, i.e., it must be just plain instructions that can be implemented in any language, and yet the output will be same, as expected.

Advantage of Algorithm

  • It is easy to understand.
  • 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.

Disadvantage of Algorithm

  • Writing an algorithm takes a long time so it is time-consuming.
  • Branching and Looping statements are difficult to show in Algorithms.

Some Example:-

1. Algorithm to add 3 numbers and print their sum:
  1. START
  2. Declare 3 Integer variable num1, num2, and num3.
  3. Take the three numbers, to be added, as inputs in variables num1, num2, num3 respectively.
  4. Declare an integer variables 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
1. Algorithm to find the area of circle
  1.  Start
  2. Declare variables: side_length (to store the length of the side of the square) and area (to store the computed area of the square).
  3. Prompt the user to input the length of the side of the square.
  4. Read the input value and store it in side_length.
  5. Calculate the area using the formula:
            area=side_length×side_length
     6. Display the computed area.
     7. End





Thank you so much for visiting on this "Edu Verse By Pratik" website. If you like this content then share it with your friends via social media as Whatsapp, Facebook, Twitter,  and other social media platform. Content for more follow the Edu Verse By Pratik. You can also join with me on youtube by visiting this URL YouTube "@code.withPratik. thanks.
            

    Post a Comment

    Previous Post Next Post