0% found this document useful (0 votes)
14 views9 pages

Understanding Algorithms and Their Components

An algorithm is a systematic procedure for solving specific problems, consisting of essential components such as input, processing, decision-making, and output. The document provides various examples of algorithms for tasks like arithmetic operations, calculating volumes of geometric shapes, unit conversions, and decision-making processes. It also outlines the problem-solving process in computing, including defining, analyzing, planning, and selecting solutions.

Uploaded by

harshitkumarusyu
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)
14 views9 pages

Understanding Algorithms and Their Components

An algorithm is a systematic procedure for solving specific problems, consisting of essential components such as input, processing, decision-making, and output. The document provides various examples of algorithms for tasks like arithmetic operations, calculating volumes of geometric shapes, unit conversions, and decision-making processes. It also outlines the problem-solving process in computing, including defining, analyzing, planning, and selecting solutions.

Uploaded by

harshitkumarusyu
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

Algorithm

An algorithm is a step-by-step procedure or set of instructions designed to solve a specific


problem.
It clearly defines what to do, how to do it, and in what order.

Essential Components of an Algorithm

Component Description
1. Input The data or values provided to the algorithm.
2. The steps or operations performed on the input
Processing data.
3. Decision Logical or conditional steps that guide the flow
(e.g., if–else).
4. Output The final result or information produced by the
algorithm.

Example Structure of an Algorithm

1. Start

2. Input data

3. Process data (apply formulas or logic)

4. Make decisions if needed

5. Output results

6. Stop
a. Performing Arithmetic Operations

Example: Add, subtract, multiply, and divide two numbers.

Algorithm:

1. Start

2. Input two numbers A and B

3. Calculate Sum = A + B

4. Calculate Difference = A - B

5. Calculate Product = A * B

6. Calculate Quotient = A / B

7. Display Sum, Difference, Product, and Quotient

8. Stop

b. Calculating Volume of Geometrical Shapes

Algorithm 1: Find Volume of a Cube

1. Start

2. Input s of the cube, Volume

3. Calculate Volume = s * s * s

4. Display Volume

5. Stop

Formula:
Volume of Cube = s³

Example:
If s = 4
Volume = 4 × 4 × 4 = 64 cubic units
Algorithm 2: Find Volume of a Cylinder

1. Start

2. Input radius (r) and height (h) of the cylinder, Volume

3. Calculate Volume = 3.14 * r * r * h

4. Display Volume

5. Stop

Formula:
Volume of Cylinder = π × r² × h

Example:
If r = 3 and h = 5
Volume = 3.14 × 3 × 3 × 5 = 141.3 cubic units

Algorithm 3: Find Volume of a Sphere

1. Start

2. Input radius (r) of the sphere

3. Calculate Volume = (4/3) * 3.14 * r * r * r

4. Display Volume

5. Stop

Formula:
Volume of Sphere = (4/3) × π × r³

Example:
If r = 6
Volume = (4/3) × 3.14 × 6 × 6 × 6 = 904.32 cubic units

Example: Find volume of cube, cylinder, and sphere.

Algorithm:

1. Start

2. Input side (s) of cube, radius (r), and height (h) of cylinder
3. Calculate Volume of Cube = s * s * s

4. Calculate Volume of Cylinder = 3.14 * r * r * h

5. Calculate Volume of Sphere = (4/3) * 3.14 * r * r * r

6. Display all volumes

7. Stop

c. Converting Units (Physical Quantities)

Example: Convert temperature from Celsius to Fahrenheit.

Algorithm:

1. Start

2. Input temperature in Celsius (C), Fahrenheit

3. Calculate Fahrenheit = (C * 9/5) + 32

4. Display Fahrenheit

5. Stop

Start

2. Input temperature in Celsius (C), Fahrenheit(F)

3. Calculate C = (F-32)/ 9/5

4. Display C

5. Stop

Example (Alternate): Convert kilometers to meters

1. Start

2. Input distance in kilometers (km), meters

3. Calculate meters = km * 1000

4. Display meters

5. Stop
d. Applying Selection Process

Example: Check if a number is even or odd.

Algorithm:

1. Start

2. Input a number N

3. If N % 2 == 0 then

4. Display "Number is Even"

Else

Display "Number is Odd"

5. Stop

e. Finding Maximum and Minimum from Input Values

Algorithm:

1. Start

2. Input three numbers A, B, and C

3. If A > B and A > C then, Max = A

Else if B > C then, Max = B

Else Max = C

4. Display Max

5. Stop
f. Real-Life Problem Example

Example: Calculate total bill after applying discount.

Algorithm:

1. Start

2. Input total amount, discount, Final Amount

3. Calculate Discount = amount * discount% / 100

4. Calculate Final Amount = amount - Discount

5. Display Final Amount

7. Stop

Example (Alternate Real-Life Case):


Finding average marks and checking if a student passed.

1. Start

2. Input marks of 3 subjects: M1, M2, M3,Average

3. Calculate Average = (M1 + M2 + M3) / 3

4. If Average >= 40 then

[Link] "Pass"

Else

Display "Fail"

5. Stop
Algorithm : ATM Cash Withdrawal

Step 1: Start
Step 2: Input – Insert ATM card and enter PIN
Step 3: Processing – Verify the PIN
Step 4: Decision – Is PIN correct?
If YES, go to Step 5
If NO, display error and ask to re-enter PIN
Step 5: Input – Enter withdrawal amount
Step 6: Processing – Check if balance is sufficient
Step 7: Decision – Is balance sufficient?
If YES, cash available
If NO, display “Insufficient Balance”
Step 8: Output – Cash and receipt provided
Step 9: Stop

Algorithm 4: Mobile Phone Unlock

Step 1: Start
Step 2: Input – PIN, pattern,password, facelock,voice lock or fingerprint
Step 3: Processing – Compare input with stored data
Step 4: Decision – Is input correct?
If YES, unlock phone
If NO, display “Incorrect Password”
Step 5: Output – Phone unlocked or error message shown
Step 6: Stop
Concept of a Problem in Computing

A problem in computing is a task or situation that requires a solution using computer


technology.
It usually involves input (data), processing (computation or logic), and output (result).

In simple words:

A computing problem is anything that needs to be solved by using a computer program or


algorithm.

Example:

• Calculating students’ grades automatically.

• Finding the shortest route in Google Maps.

• Searching a name in a contact list.

Types of Problems in Computing

1. Decision Problems

• These problems require a yes or no (true or false) answer.

• The algorithm must decide between two or more options.

Examples:

• Is the number even?

• Is the password correct?

• Is a student’s average ≥ 40?

2. Searching Problems

• The goal is to find specific data or item from a list or database.

• The computer searches for the required information among many items.

Examples:

• Searching a student’s name in a class list.

• Finding a word in a dictionary.

• Searching for a file on the computer.


3. Counting Problems

• These involve counting the number of items that meet a certain condition.

• The algorithm keeps a counter variable to track the total.

Examples:

• Counting how many students scored above 80%.

• Counting vowels in a word.

• Counting total emails in an inbox.

Steps of the Problem-Solving Process


• a. Define the Problem:
In this step, you clearly identify what needs to be solved. You should understand the
main goal of the problem.
Example: To calculate the average marks of a student.
• b. Analyse the Problem:
Here, you find out what information is needed as input and what result you want as
output. You also check any limits or special conditions.
Example: Inputs are marks in three subjects, and the output is the average of those marks.
• c. Plan the Solution:
In this step, you design a step-by-step method (algorithm or flowchart) to solve the
problem logically.
Example: Add all the marks together and divide the total by 3.
• d. Find Candidate Solutions:
Now, you think of different possible ways to solve the problem and compare them.
Example: You can use a direct mathematical formula or a built-in average function in
programming.
• e. Select the Best Solution:
Finally, you choose the method that is simplest, most accurate, and efficient.
Example: Use the direct formula in code for faster calculation.

You might also like