Unit 1: Algorithm Pseudocode Flowchart
Unit 1: Algorithm Pseudocode Flowchart
• Algorithm
• Pseudocode
• Flowchart
What is an Algorithm?
Algorithm is finite set of instructions which if executed will accomplish a specific task.
Example: searching
• input: A sequence of numbers.
• output: position of number in the list or number is not in the list.
Pseudocode
• Pseudocode is a way of writing algorithms in a simplified, informal language that resembles programming code but is
more readable and closer to human language.
• It is used to outline the logic of a program without adhering to the syntax of a specific programming language.
• Combines natural language with programming-like structures to describe the algorithm.
Flowchart
• A flowchart is a visual representation of an algorithm or process using symbols to depict different types of operations
and directions to show the flow of control.
• It provides a graphical way of understanding and designing the sequence of steps in a process.
Summary
• Algorithm: A conceptual, step-by-step procedure for solving a problem.
• Pseudocode: A readable, informal code-like representation of an algorithm.
• Flowchart: A visual diagram that illustrates the steps and decisions in a process or algorithm.
Each of these methods serves a different purpose: algorithms define the logic, pseudocode outlines the logic in an informal
code-like manner, and flowcharts provide a visual representation of the process.
Example-Logic
• Linear Search is a straightforward searching algorithm used to find the position of a target value within a list. It
checks each element in the list sequentially until the desired element is found or the list ends.
Example-Algorithm
1. Start from the first element of the list.
2. Compare the current element with the target element.
3. If the current element matches the target element, return the index (position) of the current element.
4. If the current element does not match the target element, move to the next element in the list.
5. Repeat steps 2-4 until you reach the end of the list.
6. If the target element is not found in the list, return a value indicating that the element is not present (e.g., -1 or Not
Found).
Example-Pseudocode
1. function LinearSearch(list, target):
2. for i = 0 to length(list) - 1:
3. if list[i] == target:
4. return i
5. return -1 // Target not found
list: The array in which we want to search for the target value.
target: The value we are searching for in the list.
i: The index variable used to iterate through the list.
Example-Pseudocode
1. function LinearSearch(list, target):
2. for i = 0 to length(list) - 1:
3. if list[i] == target:
4. return i
5. return -1 // Target not found
list: The array in which we want to search for the target value.
target: The value we are searching for in the list.
i: The index variable used to iterate through the list.
Thank You