What is ProblemSolving?
• Problem solving is the process of identifying a problem, creating a plan, and implementing a solution.
• In programming, it involves:
• • Understanding the problem
• • Designing an algorithm
• • Writing code
• • Testing and refining
3.
Understanding the Problem
•Clearly define inputs, outputs, and constraints before solving.
• Example: Given three numbers, find their average.
4.
Decomposition
• Break abig problem into smaller sub-problems.
• Example: Sort student marks → input, compare, swap, output.
Abstraction
• Ignore irrelevantdetails, focus on essentials.
• Example: ATM withdrawal focuses on amount & PIN, not machine internals.
11.
Divide and Conquer
•Split into parts, solve each, then combine.
• Example: Binary search in a dictionary.
12.
Optimization
• Improve anexisting solution for efficiency.
• Example: Find largest number with fewer comparisons.
13.
Example Problem
• Checkif a number is Even or Odd.
• Inputs: Number n
• Outputs: 'Even' or 'Odd'
14.
Algorithm for Even/OddCheck
• 1. Start
• 2. Read n
• 3. If n % 2 == 0, print 'Even'
• 4. Else, print 'Odd'
• 5. Stop
15.
Flowchart Description
• Start→ Input n → Decision: n % 2 == 0?
• Yes → Output 'Even' → Stop
• No → Output 'Odd' → Stop
16.
Summary & KeyTakeaways
• • Problem solving needs clear understanding & planning
• • Use strategies like decomposition, pattern recognition, and optimization
• • Always test and refine your solutions
• • Flowcharts and algorithms make solutions clear and structured