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

Algorithms

An algorithm is a finite set of well-defined steps designed to solve a problem or perform a computation. It must have properties such as clear inputs and outputs, finiteness, effectiveness, and determinism. Algorithms are essential in various fields for automating processes and solving complex problems efficiently.

Uploaded by

Ankit Garg
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)
17 views3 pages

Algorithms

An algorithm is a finite set of well-defined steps designed to solve a problem or perform a computation. It must have properties such as clear inputs and outputs, finiteness, effectiveness, and determinism. Algorithms are essential in various fields for automating processes and solving complex problems efficiently.

Uploaded by

Ankit Garg
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

What is an Algorithm

Algorithm is a set of finite, well-defined steps or instructions designed to solve a problem or


perform a computation. It can also be defined as a procedure for solving a mathematical or
computational problem in a finite number of steps, often involving repetitive or recursive
operations.

Need for Algorithms:

• Solve complex problems efficiently and effectively.


• Automate processes, making them reliable, faster, and easier.

• Enable computers to perform tasks difficult or impossible for humans.

• Widely used in mathematics, computer science, engineering, finance, and data analysis.

PROPERTIES OF AN ALGORITHM
An algorithm is a precise set of instructions to solve a problem. For a set of instructions to
qualify as an algorithm, it must have the following properties:
Clear and Unambiguous:

• Each step should be precise and lead to only one interpretation.

Well-Defined Inputs:

• An algorithm may take zero or more inputs, which must be clearly specified.

Well-Defined Outputs:
• It must produce at least one output, clearly defined.

Finiteness:

• The algorithm must terminate after a finite number of steps.


• Infinite loops or recursion without base conditions violate this property.

Effectiveness:

• Steps should be simple, feasible, and executable with available resources.


Deterministic:

• For the same input, the algorithm should always produce the same output.

Language Independent:

• Algorithms are plain instructions and can be implemented in any programming


language, producing the same result.

STEPS TO DESIGN AN ALGORITHM


To design an algorithm, the following prerequisites must be considered:
1. Problem Definition: Clearly define the problem to be solved.

2. Constraints: Identify any limitations or rules.

3. Inputs: Determine what data will be provided.

4. Outputs: Specify the expected results.


5. Solution Feasibility: Ensure the solution works within the given constraints.
Algorithm to Add Two Numbers and Display the Result
Step 1: Start.
Step 2: Declare two variables, say num1 and num2, to store the two numbers.

Step 3: Input the value of num1.

Step 4: Input the value of num2.

Step 5: Calculate the sum by adding num1 and num2, store result in sum.

Step 6: Display the value of sum.


Step 7: End.

ALGORITHM : To find the largest of 2 numbers


Step 1: START

Step 2: Declare variables a, b.

Step 3: If a > b , print "A is largest"

Step 4: Else print "B is largest"

Step 6: STOP

Algorithm to Find the Largest of Three Numbers


Given three numbers, the goal is to find the largest one among them.
Algorithm:

1. Start

2. Input three numbers: A, B, and C

3. Initialize a variable largest with the value of A

4. Compare largest with B, If B > largest, then largest = B


5. Compare largest with C, If C > largest, then largest = C

6. Output the value of largest

7. End

You might also like