0% found this document useful (0 votes)
16 views2 pages

Algo

An algorithm is a finite sequence of well-defined instructions that provides a solution to a problem based on given inputs. It must have specific properties including input, output, finiteness, definiteness, and effectiveness. Two examples illustrate basic algorithms for summing two numbers and swapping their values.

Uploaded by

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

Algo

An algorithm is a finite sequence of well-defined instructions that provides a solution to a problem based on given inputs. It must have specific properties including input, output, finiteness, definiteness, and effectiveness. Two examples illustrate basic algorithms for summing two numbers and swapping their values.

Uploaded by

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

Algorithm

Example 1

Step 1: Start
Step 2: Input first number as P
Step 3: Input second number as Q
Step 3: Set Sum=P+Q
Step 5: Print Sum
Step 6: End.

• An algorithm is a strictly defined finite sequence of


well defined statements (often called instructions or
commands) that provide the solution to a problem or
to a specific class of problems for any acceptable set of
input values (if there are any inputs).
• In other words, an algorithm is a step-by-step
procedure to solve a given problem.
• The term “finite” means that the algorithm should
reach an end point and cannot run forever.

An algorithm must satisfy the following properties:


• Input: The algorithm must have input values from a
specified set.
• Output: The algorithm must produce the output
values from a specified set of input values. The output
values are the solution to a problem.
• Finiteness: For any input, the algorithm must
terminate after a finite number of steps.
• Definiteness: All steps of the algorithm must be
precisely defined.
• Effectiveness: It must be possible to perform each
step of the algorithm correctly and in a finite amount
of time. That is, its steps must be basic enough. It is not
enough that each step is definite (or precisely defined),
but it must also be feasible.

Example 2

Step 1: Start
Step 2: Input value of first number in P
Step 3: Input value of second number in Q
Step 4: Set Temp = P
Step 5: Set P = Q
Step 6: Set Q= Temp
Step 7: Print P and Q
Step 8: End.

You might also like