What is ProblemSolving?
•Problem solving is identifying a
problem, planning a solution,
implementing it, and testing it.
•In programming, it involves:
• Understanding the problem
• Designing an algorithm
• Writing code
• Testing & refining
3.
Why Problem-Solving SkillsMatter
•They make you efficient and logical
• Help in debugging & optimization
• Build transferable skills across
domains
• Essential for competitive
programming & interviews
4.
Understanding the Problem
•Define inputs, outputs, and constraints
before solving.
• Example: Find average of three numbers.
5.
Understanding the Problem- Real-World Example
•A scenario where understanding the
problem is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
6.
Understanding the Problem- Programming Example
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
7.
Decomposition
•Break a bigproblem into smaller sub-
problems.
•Example: Sorting → input, compare,
swap, output.
8.
Decomposition - Real-WorldExample
•A scenario where decomposition is
applied in daily life.
•• Practical situation
•• Outcome after applying strategy
9.
Decomposition - ProgrammingExample
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
Pattern Recognition -Real-World Example
•A scenario where pattern
recognition is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
12.
Pattern Recognition -Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
13.
Working Backwards
•Start fromthe goal and trace steps to
the start.
•Example: Find starting amount if final
is 200 after doubling 3 times.
₹
14.
Working Backwards -Real-World Example
•A scenario where working backwards
is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
15.
Working Backwards -Programming Example
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
16.
Trial and Error
•Testmultiple approaches until one
works.
•Example: Guessing a combination
lock.
17.
Trial and Error- Real-World Example
• A scenario where trial and error is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
18.
Trial and Error- Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Algorithmic Thinking -Real-World Example
• A scenario where algorithmic thinking is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
21.
Algorithmic Thinking -Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Use of Models/Flowcharts- Real-World Example
• A scenario where use of models/flowcharts is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
24.
Use of Models/Flowcharts- Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Abstraction - Real-WorldExample
• A scenario where abstraction is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
27.
Abstraction - ProgrammingExample
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
28.
Divide and Conquer
•Splitinto parts, solve each, then
combine.
•Example: Binary search in a sorted
list.
29.
Divide and Conquer- Real-World Example
• A scenario where divide and conquer is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
30.
Divide and Conquer- Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Optimization - Real-WorldExample
• A scenario where optimization is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
33.
Optimization - ProgrammingExample
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
34.
Worked Example: Even/OddCheck
• Problem: Check if a number is even or odd.
• Inputs: Number n
• Outputs: 'Even' or 'Odd'
• Algorithm:
• 1. Start
• 2. Read n
• 3. If n % 2 == 0 → Even else Odd
• 4. Stop
35.
Flowchart for Even/Odd
•Start → Input n → Decision (n % 2 == 0?)
• Yes → Even → Stop
• No → Odd → Stop
Summary of Strategies
•
•Understanding the Problem → Define clearly
• • Decomposition → Break down tasks
• • Pattern Recognition → Use past knowledge
• • Working Backwards → Reverse approach
• • Trial and Error → Test multiple ways
• • Algorithmic Thinking → Stepwise plan
• • Use of Models/Flowcharts → Visual clarity
• • Abstraction → Focus on essentials
• • Divide and Conquer → Solve in parts
• • Optimization → Make it efficient
38.
Practice Questions
•1. Findfactorial of a number
•2. Check if a string is palindrome
•3. Search an element in a sorted list
•4. Optimize bubble sort
•5. Convert Celsius to Fahrenheit
•6. ATM cash withdrawal simulation
39.
Find Factorial ofa Number
•Algorithm:
•1. Start
•2. Read n
•3. fact = 1
•4. Repeat fact = fact * i for i=1 to n
•5. Print fact
•6. Stop
40.
Find Factorial ofa Number - Flowchart
•Flowchart: Start → Input n → Loop
i=1 to n → fact=fact*i → End loop
→ Output fact → Stop
41.
Find Factorial ofa Number - C Code
• #include <stdio.h>
• int main()
• {
• int n,i; long fact=1;
• scanf("%d", &n);
• for(i=1;i<=n;i++)
• fact*=i;
• printf("%ld",fact);
• return 0;
• }
42.
Check if aString is Palindrome
•Algorithm:
•1. Start
•2. Read string
•3. Compare first and last characters
•4. If all match → Palindrome else Not
•5. Stop
43.
Check if aString is Palindrome - Flowchart
•Flowchart: Start → Input string →
Compare chars → Decision → Output
result → Stop
44.
Check if aString is Palindrome - C Code
• #include <stdio.h>
• #include <string.h>
• int main()
• {
• char str[100]; int i,flag=0; gets(str);
for(i=0;i<strlen(str)/2;i++)
• if(str[i]!=str[strlen(str)-i-1])
• flag=1; if(flag==0)
• printf("Palindrome");
• else printf("Not"); return
• 0;}
45.
Key Takeaways
• •Apply the right strategy for the problem type
• • Always write algorithms before coding
• • Test with edge cases
• • Refine for efficiency
• • Practice regularly