0% found this document useful (0 votes)
5 views

Algorithm and Pseudocode

An algorithm is a step-by-step procedure for solving a problem, characterized by inputs, outputs, definiteness, finiteness, effectiveness, generality, and correctness. Pseudocode is a way to express algorithms in plain language, aiding in the understanding and translation into programming code. The document includes examples of algorithms and pseudocode for finding the largest number among given inputs.

Uploaded by

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

Algorithm and Pseudocode

An algorithm is a step-by-step procedure for solving a problem, characterized by inputs, outputs, definiteness, finiteness, effectiveness, generality, and correctness. Pseudocode is a way to express algorithms in plain language, aiding in the understanding and translation into programming code. The document includes examples of algorithms and pseudocode for finding the largest number among given inputs.

Uploaded by

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

ALGORITHM

AND
PSEUDOCODE
UNDERSTANDING BASICS WITH EXAMPLES
WHAT IS AN ALGORITHM?

• - An algorithm is a step-by-step procedure to solve a problem.


• - It consists of a finite number of steps.
• - Used in computing and problem-solving.
CHARACTERISTICS OF AN ALGORITHM

• - **Input**: Takes zero or more inputs.


• - **Output**: Produces at least one output.
• - **Definiteness**: Each step is clearly defined.
• - **Finiteness**: Must complete in a finite number of steps.
• - **Effectiveness**: Each step must be simple enough to be executed.
EXAMPLE WITH CHARACTERISTICS
APPLIED

1.Start.
2. Take an array of numbers as input.
3. Assume the first number is the largest (max = arr[0]).
4. Loop through the array from the second element to the last:
• If the current element is greater than max, update max.
5. After the loop ends, max contains the largest number.
6. Print max.
7. Stop.
CHECKING THE CHARACTERISTICS:

1. Well-Defined Inputs – The algorithm takes an array as input.


2. Well-Defined Outputs – It produces the largest number in the array.
3. Definiteness – Each step is clear and precise.
4. Finiteness – The loop runs a finite number of times (equal to the array length).
5. Effectiveness – Uses basic operations (comparison and assignment).
6. Generality – Works for any numerical array.
7. Correctness – Always finds the largest number correctly.
WHAT IS PSEUDOCODE?

• - A way of writing algorithms using plain language and programming logic.


• - It is **not** actual code but helps in designing logic before coding.
• Pseudocode is language-agnostic, meaning it can be translated into any
programming language."
• - Helps in easy understanding of logic before implementation.
DIFFERENCE BETWEEN ALGORITHM
AND PSEUDOCODE

• - **Algorithm**: A conceptual step-by-step process.


• - **Pseudocode**: A structured way to express an algorithm in
human-readable format.
• - Pseudocode helps in translating an algorithm into actual
programming code.
EXAMPLE: FINDING THE LARGEST
NUMBER
• **Algorithm:**
• 1. Start
• 2. Take three numbers: A, B, and C
• 3. Compare A with B and C
• 4. If A is largest, print A
• 5. Else compare B with C
• 6. If B is largest, print B
• 7. Else print C
• 8. Stop
BEGIN
INPUT A, B, C
IF A > B AND A > C THEN
PRINT "A is the largest"
ELSE IF B > C THEN
PRINT "B is the largest“
ELSE
PRINT "C is the largest“
ENDIF
END
FLOWCHART: FINDING THE LARGEST
NUMBER
FLOWCHART SYMBOLS USED:

• Oval (Start/Stop) – Represents the start and end of the


flowchart.
• Parallelogram (Input/Output) – Represents input (taking
values) and output (printing results).
• Rectangle (Process) – Represents processing steps like
comparisons.
• Diamond (Decision) – Represents conditional checks
(e.g., A > B?).
THE END
Marjan Durrani

You might also like