CORE PROBLEM-
SOLVING STRATEGIES
Logic, Algorithms, Flowcharts & Examples
What is Problem Solving?
•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
Why Problem-Solving Skills Matter
•They make you efficient and logical
• Help in debugging & optimization
• Build transferable skills across
domains
• Essential for competitive
programming & interviews
Understanding the Problem
• Define inputs, outputs, and constraints
before solving.
• Example: Find average of three numbers.
Understanding the Problem - Real-World Example
•A scenario where understanding the
problem is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
Understanding the Problem - Programming Example
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
Decomposition
•Break a big problem into smaller sub-
problems.
•Example: Sorting → input, compare,
swap, output.
Decomposition - Real-World Example
•A scenario where decomposition is
applied in daily life.
•• Practical situation
•• Outcome after applying strategy
Decomposition - Programming Example
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
Pattern Recognition
•Identify similarities to problems solved
before.
•Example: Fibonacci → n = n-1 + n-2.
Pattern Recognition - Real-World Example
•A scenario where pattern
recognition is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
Pattern Recognition - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Working Backwards
•Start from the goal and trace steps to
the start.
•Example: Find starting amount if final
is 200 after doubling 3 times.
₹
Working Backwards - Real-World Example
•A scenario where working backwards
is applied in daily life.
•• Practical situation
•• Outcome after applying strategy
Working Backwards - Programming Example
•Sample problem statement:
•• Algorithm steps
•• Possible code snippet
•• Output demonstration
Trial and Error
•Test multiple approaches until one
works.
•Example: Guessing a combination
lock.
Trial and Error - Real-World Example
• A scenario where trial and error is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
Trial and Error - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Algorithmic Thinking
•Write step-by-step logical instructions.
•Example: Check if a number is prime.
Algorithmic Thinking - Real-World Example
• A scenario where algorithmic thinking is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
Algorithmic Thinking - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Use of Models/Flowcharts
•Represent the process visually.
•Example: Cinema ticket booking
steps.
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
Use of Models/Flowcharts - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Abstraction
•Ignore irrelevant details, focus on
essentials.
•Example: ATM withdrawal focuses on
PIN and amount.
Abstraction - Real-World Example
• A scenario where abstraction is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
Abstraction - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Divide and Conquer
•Split into parts, solve each, then
combine.
•Example: Binary search in a sorted
list.
Divide and Conquer - Real-World Example
• A scenario where divide and conquer is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
Divide and Conquer - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Optimization
•Improve an existing solution for
efficiency.
•Example: Find largest number with
fewer comparisons.
Optimization - Real-World Example
• A scenario where optimization is applied in daily life.
• • Practical situation
• • Outcome after applying strategy
Optimization - Programming Example
• Sample problem statement:
• • Algorithm steps
• • Possible code snippet
• • Output demonstration
Worked Example: Even/Odd Check
• 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
Flowchart for Even/Odd
• Start → Input n → Decision (n % 2 == 0?)
• Yes → Even → Stop
• No → Odd → Stop
C Code for Even/Odd
•#include <stdio.h>
•int main() {
• int n; printf("Enter number: ");
• scanf("%d", &n);
• if (n % 2 == 0) printf("Even");
• else printf("Odd");
• return 0; }
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
Practice Questions
•1. Find factorial 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
Find Factorial of a 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
Find Factorial of a Number - Flowchart
•Flowchart: Start → Input n → Loop
i=1 to n → fact=fact*i → End loop
→ Output fact → Stop
Find Factorial of a 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;
• }
Check if a String is Palindrome
•Algorithm:
•1. Start
•2. Read string
•3. Compare first and last characters
•4. If all match → Palindrome else Not
•5. Stop
Check if a String is Palindrome - Flowchart
•Flowchart: Start → Input string →
Compare chars → Decision → Output
result → Stop
Check if a String 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;}
Key Takeaways
• • Apply the right strategy for the problem type
• • Always write algorithms before coding
• • Test with edge cases
• • Refine for efficiency
• • Practice regularly

core_problem_solving_strategies_expanded.pptx

  • 1.
    CORE PROBLEM- SOLVING STRATEGIES Logic,Algorithms, Flowcharts & Examples
  • 2.
    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
  • 10.
    Pattern Recognition •Identify similaritiesto problems solved before. •Example: Fibonacci → n = n-1 + n-2.
  • 11.
    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
  • 19.
    Algorithmic Thinking •Write step-by-steplogical instructions. •Example: Check if a number is prime.
  • 20.
    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
  • 22.
    Use of Models/Flowcharts •Representthe process visually. •Example: Cinema ticket booking steps.
  • 23.
    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
  • 25.
    Abstraction •Ignore irrelevant details,focus on essentials. •Example: ATM withdrawal focuses on PIN and amount.
  • 26.
    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
  • 31.
    Optimization •Improve an existingsolution for efficiency. •Example: Find largest number with fewer comparisons.
  • 32.
    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
  • 36.
    C Code forEven/Odd •#include <stdio.h> •int main() { • int n; printf("Enter number: "); • scanf("%d", &n); • if (n % 2 == 0) printf("Even"); • else printf("Odd"); • return 0; }
  • 37.
    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