Lecture Notes: Algorithms
1. What is an Algorithm?
An algorithm is a step-by-step procedure used to solve a problem.
2. Relationship (Problem Solving → Algorithm)
Problem solving is thinking, while algorithm is writing those thoughts into steps.
3. Characteristics of a Good Algorithm
- Clear
- Finite
- Has input
- Has output
- Efficient
4. Structure of an Algorithm
- Start
- Input
- Process
- Output
- End
5. Real-Life Examples
Tea Making: Boil water → Add tea → Add sugar → Add milk → Serve
Morning Routine: Wake up → Brush → Bath → Dress → Breakfast
Mobile Unlock: Press button → Enter password → Unlock
6. Programming Examples
Addition: Input A,B → Sum = A+B → Output
Average: Input A,B,C → Avg = (A+B+C)/3
Even/Odd: If number %2==0 → Even else Odd
Largest: If A>B → A else B
7. Types of Algorithms
- Sequential
- Decision-Based
- Loop-Based
8. Importance of Algorithms
- Foundation of programming
- Makes problems easier
- Saves time and effort
- Provides efficient solutions
Final Thought:
A good programmer first designs a clear algorithm before coding.