Algorithm Notes
Algorithm Notes
Designing an Algorithm:
Step 1: Understand the Problem: Clearly define the problem you are trying to solve.
Step 2: Identify Inputs and Outputs: Determine what inputs are needed and what
outputs are expected.
Step 3: Outline the Steps: Break down the problem into a series of steps or stages.
Step 4: Write the Pseudocode: Write a high-level representation of the algorithm in
plain English or pseudocode.
Step 5: Test the Algorithm: Run through the algorithm with different inputs to ensure it
works as expected.
START
INPUT number1, number2
SET sum = number1 + number2
PRINT sum
END
Types of Algorithms:
Search Algorithms: Find specific data within a data set (e.g., linear search, binary
search).
Sorting Algorithms: Arrange data in a specific order (e.g., bubble sort, merge sort,
quicksort).
Recursive Algorithms: Solve a problem by solving smaller instances of the same
problem (e.g., calculating factorial, Fibonacci series).
Greedy Algorithms: Make the most optimal choice at each step (e.g., Dijkstra’s
algorithm for shortest path).
Dynamic Programming Algorithms: Break down problems into smaller overlapping
subproblems and solve them once (e.g., solving the knapsack problem).
What is a Flowchart?
Step 1: Identify the Problem: Clearly define the problem you are trying to solve.
Step 2: Break Down the Problem: Divide the problem into smaller, manageable steps.
Step 3: Draw the Flowchart: Use the appropriate symbols to represent each step of the
process. Ensure logical flow from start to finish.
Step 4: Review and Refine: Check for any logical errors or redundancies. Adjust the
flowchart as needed.
What is Programming?
Introduction to Python:
History of Python:
o Developed by Guido van Rossum in the late 1980s and released in 1991.
o The philosophy behind Python: simplicity, readability, and flexibility.
Why Python?
o Easy-to-read syntax, which mimics natural language.
o Versatile and widely used in various fields, such as web development, data
science, machine learning, automation, and more.
o Strong community support and extensive libraries.
Writing a simple "Hello, World!" program to introduce the basic structure of Python
scripts.
Understanding the print() function and basic output.
Introduction to comments and their purpose in code.
Basic syntax rules (indentation, case sensitivity, line breaks).