PROGRAMMING &
ALGORITHM
ENGR. JOYCE C. BERNADOS, IE,MAED-AS,LPT,(RES) PA
WHAT IS ALGORITHM?
An algorithm is a well-defined procedure
that takes some input and produces a
corresponding output. It's a set of
instructions that is used to solve a specific
problem or perform a particular task.
What is Programming?
Programming is the process of
designing, writing, testing,
debugging and maintaining
software programs using
programming languages.
Everyday Life Algorithms
Recipe Algorithm:
Input: Ingredients (flour, sugar, eggs, etc.)
Steps: Mix, bake, decorate
Output: A delicious cake!
Getting Ready for Work Algorithm:
Input: Wake-up time, work schedule
Steps: Wake up, brush teeth, shower, dress, have breakfast
Output: Being ready for work on time!
Mathematical Algorithms
Addition Algorithm:
Input: Two numbers (a, b)
Steps: Add a and b
Output: The sum of a and b
Algorithm: Find Maximum of Two Numbers
Input: a, b (two numbers)
1. If a > b then
2. max = a
3. Else
4. max = b
5. Return max
Here are some common sets of algorithms used to solve
various problems:
1. Sorting Algorithms
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Heap Sort
Used for: Arranging data in ascending or descending
order.
2. Searching Algorithms
Linear Search
Binary Search
Depth-First Search (DFS)
Breadth-First Search (BFS)
Used for: Finding specific data
within a dataset.