PROBLEM SOLVING AND ALGORITHM DESIGN
Comprehensive University Lecture Note
Course: Introduction to Computer Science
Level: Undergraduate
Prepared for Academic Submission
1. Introduction to Problem Solving
Problem solving in computer science involves identifying a problem, analyzing it logically, designing
a structured solution (algorithm), implementing it, and evaluating its efficiency.
Steps in Problem Solving:
• Define the problem clearly
• Analyze inputs, outputs, and constraints
• Design the algorithm
• Implement in a programming language
• Test and debug
2. Introduction to Algorithms
An algorithm is a finite, step-by-step procedure used to solve a specific problem.
Properties of Algorithms:
• Input
• Output
• Definiteness
• Finiteness
• Effectiveness
3. Worked Example: Finding the Maximum of Two Numbers
BEGIN
INPUT A, B
IF A > B THEN
PRINT A
ELSE
PRINT B
END
Example: If A = 10 and B = 5, the algorithm compares both values and outputs 10.
4. Flowchart Diagram (Worked Example)
Start
Input A, B
A>B?
Print Result
End
5. Algorithm Design Techniques
• Brute Force
• Divide and Conquer
• Greedy Method
• Dynamic Programming
• Recursion
6. Time and Space Complexity
Big O notation measures the efficiency of algorithms.
Notation Meaning
O(1) Constant Time
O(n) Linear Time
O(n^2) Quadratic Time
O(log n) Logarithmic Time
7. Worked Example: Linear Search
BEGIN
INPUT array, key
FOR each element in array
IF element == key
RETURN position
END FOR
RETURN not found
END
8. Examination Questions
• 1. Define an algorithm and list its properties.
• 2. Differentiate between flowchart and pseudocode.
• 3. Explain Big O notation with examples.
• 4. Design an algorithm to calculate factorial of a number.
• 5. Compare linear search and binary search.
9. Suggested Answers
Answers should include clear definitions, structured explanations, examples, and diagrams where
necessary.
10. Conclusion
Problem solving and algorithm design form the foundation of computer science. Mastering these
concepts prepares students for advanced programming, software engineering, AI, and data
science.