0% found this document useful (0 votes)
2 views1 page

Understanding Algorithms: Basics & Examples

Uploaded by

kimshana37
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)
2 views1 page

Understanding Algorithms: Basics & Examples

Uploaded by

kimshana37
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

Short Notes on Algorithms

What is an Algorithm?
An algorithm is a step-by-step procedure or set of rules to solve a specific problem or perform a
task. It is like a cooking instruction that tells the computer exactly what to do in a sequence.

Basics of Algorithms:
• Algorithms have input (data given) and output (result).
• They are written in simple steps (sequence of instructions).
• They must be clear, finite (end after some steps), and effective.
• Algorithms can be represented using natural language, pseudocode, or flowcharts.

Examples of Algorithms:

Example 1: Find the largest of two numbers


1 Step 1: Start
2 Step 2: Input two numbers, A and B
3 Step 3: If A > B, then print A is largest
4 Step 4: Else, print B is largest
5 Step 5: Stop

Example 2: Calculate the sum of first N natural numbers


1 Step 1: Start
2 Step 2: Input N
3 Step 3: Set Sum = 0
4 Step 4: Add numbers from 1 to N one by one into Sum
5 Step 5: Print Sum
6 Step 6: Stop

You might also like