0% found this document useful (0 votes)
5 views3 pages

Introduction to DAA(Design and Analysis of Algorithms)

The document provides an introduction to Design and Analysis of Algorithms (DAA), explaining what an algorithm is and its characteristics, advantages, and disadvantages. It outlines the steps to design an algorithm, including understanding the problem, constraints, input, expected output, and the solution. An example of a simple algorithm for adding two numbers is also provided to illustrate the design and implementation process.

Uploaded by

Mihir Panchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Introduction to DAA(Design and Analysis of Algorithms)

The document provides an introduction to Design and Analysis of Algorithms (DAA), explaining what an algorithm is and its characteristics, advantages, and disadvantages. It outlines the steps to design an algorithm, including understanding the problem, constraints, input, expected output, and the solution. An example of a simple algorithm for adding two numbers is also provided to illustrate the design and implementation process.

Uploaded by

Mihir Panchal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to DAA(Design and Analysis of Algorithms)

DAA- Design and Analysis of Algorithms is something that will help you in judging an
algorithm based on the requirements and to help you in deciding if it’s a perfect fit for that
problem.

Introduction – What is an Algorithm?

An algorithm is a process or a set of well-defined instructions or rules that specify a


sequence of operations to be followed in order to solve a problem. In other words, an
algorithm is a sequence of commands that takes an input and results in expected output.

We can find algorithms anywhere around us. For example, to cook a new dish we need to
know the recipe. A recipe is a set of instructions that guides one in preparing a dish. If you
follow the recipe perfectly, you will get a delicious dish. This is similar to the case of the
algorithm, if one follows the algorithm correctly, it will result in the expected output.

An algorithm is independent of the language used. As an algorithm is just a set of rules, it


can be implemented in any language.

Characteristics of an Algorithm

An algorithm is not just a set of rules, instead, it is a set of well-defined rules. For an
algorithm to be called standard it must consist of the following characteristics:

• An algorithm must only take in well-defined input.

• An algorithm must yield a clear and well-defined output.

• An algorithm must be finite, i.e., it should not consist of infinite loops.

• An algorithm must be feasible, i.e., it must be simple and generic such that it will be
executed with the resources available.

• An algorithm must be flexible in order to make required changes.

• An algorithm must be clear and unambiguous, i.e., it must have a single conclusion.

• An algorithm must be language-independent as discussed above.


Advantages of Algorithms:

• Algorithms are easy to understand.

• Algorithms make it easy to understand and implement an actual program.

• An algorithm eases debugging to detect any logical errors in the program.

• An algorithm is language-independent.

Disadvantages of Algorithms:

• Designing an algorithm for complex problems can be time-consuming.

• Loops and branching statements are difficult to represent in an algorithm.

• For complex problems, it is difficult to understand the logic through algorithms.

Designing an Algorithm

Now that we have an idea of the characteristics of an algorithm, let’s have a look into how to
design an algorithm and what are the steps to be followed.

Prerequisites needed in order to design an algorithm:

• Understand the problem that is to be solved by the algorithm.

• Have an idea about the constraints that are to be considered while solving the
problem.

• Input that is required to solve the problem.

• Expected output, once the problem is solved.

• Finally, the solution to the problem with given constraints.

We then design an algorithm by considering all the above parameters.

Steps to design an algorithm:

Step 1: Fulfilling all the prerequisites

Step 2: Designing an algorithm using the prerequisites

Step 3: Implementing the algorithm


Example of Algorithm:

Let us have a look into the algorithm of the addition of two numbers.

Step 1: Start

Step 2: Declare two integer variables, ‘a’ and ‘b’.

Step 3: Read two numbers that are to be stored in ‘a’ and ‘b’ respectively.

Step 4: Declare an integer variable to store the sum of 2 numbers. Let’s call it ‘c’.

Step 5: Add the 2 numbers and store the result in variable ‘c’.

Step 6: Print the value of ‘c’.

Step 7: End

Let’s see how the 3 steps discussed earlier work in the case of this example:

Step 1:

• Problem to be solved: To add two numbers and print their sum.

• Constraints involved: As we are adding digits, the constraint is to take only digits and
not characters.

• Input to be taken: We take the values of “a” and “b” which are to be added.

• Expected output: We expect to get the sum of “a” and “b”.

• Solution: The solution is to add 2 numbers. We can do so using the “+” operator, the
bitwise operator, or any other method.

Step 2:

Designing an algorithm for this problem consists of the 7 steps as discussed earlier.

Step 3:

Implementation of the algorithm can be done in any language of your choice.

These three steps can be used to design and implement an algorithm for any problem.
Continue reading the next article to know about pseudocode and how to write a
pseudocode for expressing algorithms.

You might also like