0% found this document useful (0 votes)
10 views10 pages

Week1 Introduction To Algorithm Design and Analysis

Uploaded by

Jamaica Davila
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)
10 views10 pages

Week1 Introduction To Algorithm Design and Analysis

Uploaded by

Jamaica Davila
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/ 10

INTRODUCTION TO ALGORITHM DESIGN

AND ANALYSIS

PREPARED BY: MR. ALVIN C. CATALON


COURSE OUTLINE 2

• Understand the importance of algorithm design and analysis.


• Learn about common algorithmic strategies.
• Recognize why computational complexity matters.
IMPORTANCE OF ALGORITHM DESIGN AND ANALYSIS

Definition:
• An algorithm is a finite set of well-defined instructions that
take input, process it, and produce output. Algorithm design is
about coming up with a step-by-step solution, while analysis is
about evaluating how good that solution is (speed, efficiency,
memory use).

Importance:
• Ensures correctness (produces the right result for all inputs).
• Improves efficiency (saves time and resources).
• Enables scalability (works well for large data sets).
• Guides problem-solving logically.
IDENTIFYING DIFFERENT ALGORITHMIC STRATEGIES
Common Strategies:
• Brute Force – Try all possible solutions.
• Divide and Conquer – Break the problem into smaller subproblems,
solve, and combine.
• Greedy Algorithms – Make the best local choice at each step, hoping
it leads to the global best.
• Dynamic Programming – Solve problems by storing results of
subproblems to avoid recalculating.
COMPUTATIONAL COMPLEXITY 5

Definition:
• Computational complexity measures the resources (time and
memory) an algorithm needs to run.
Key Concepts:
We use Big-O notation to measure how an algorithm scales as
input grows.
• O(1): Constant time – fastest, no matter the input size.
• O(n): Linear time – grows proportionally with input.
• O(log n): Logarithmic – very efficient, grows slowly.
• O(n²): Quadratic – slower, often from nested loops.
DEFINITIONS, THEORIES, AND LESSONS 6

Key Terms:
• Algorithm: Step-by-step procedure for solving a problem.
• Pseudocode: A human-readable description of algorithm
logic.
• Correctness: An algorithm produces the correct result for all
inputs.
• Efficiency: Optimal use of time and memory.
• Big-O Notation: Mathematical notation to classify
algorithms by performance.

Lesson Summary:
• Algorithms are central to problem-solving in computer
science.
• Good design impacts performance dramatically.
• Strategies vary based on problem type.
• Computational complexity allows comparison between
algorithms.
EXAMPLES 7

Example 1: Finding the Example 2: Binary


Maximum Number in a List Search
Problem: Given numbers [12, 7, 25, Problem: Find the
9, 30], find the maximum. number 25 in a sorted list
Solution: [5, 10, 15, 20, 25, 30].
• Start with first number (12). Solution:
• Compare with next: 12 vs 7 → Start in the middle (15).
keep 12.
• 25 > 15 → search right
• Compare 12 vs 25 → update to
half [20, 25, 30].
25.
• Compare 25 vs 9 → keep 25.
• Middle of right half =
25. Found!
• Compare 25 vs 30 → update to
30. Analysis: This is O(log n)
because we cut the list in
Final answer: 30.
half each time.
Analysis: Runs in O(n) because we
check each number once.
EXAMPLES 8

Example 3: Checking for Prime Number


Problem: Is 29 prime?
Solution:
• Prime means divisible only by 1 and itself.
• Check divisibility from 2 up to √29 ≈ 5.
• 29 ÷ 2? No. 29 ÷ 3? No. 29 ÷ 5? No.
• No divisors found → 29 is prime.
Analysis: More efficient than checking all numbers up to 29
(brute force).
ACTIVITY 9

Activity: Choose the Best Algorithm


Instructions:
Read each problem below. Decide which algorithmic strategy (Brute Force,
Divide and Conquer, Greedy, or Dynamic Programming) is best suited for
solving it. Write your answer and explain briefly why it fits.
• Problem 1: Searching for Your Lost ID (You lost your ID card inside your
messy room. You decide to check every corner, drawer, and bag one by
one until you find it.)
• Question: Which algorithmic strategy are you using?
• Problem 2: Tournament Singing Contest (The teacher divides the whole
class into small groups. Each group selects one winner, then the winners
compete against each other until the best singer is chosen.)
• Question: Which algorithmic strategy is used
• Problem 3: Choosing the Fastest Line in the Canteen (You enter the
canteen and immediately pick the shortest line without checking the
others.)
• Question: Which algorithmic strategy is used?
THANK
YOU

You might also like