What is Problem Solving?
Problem solving means finding a way to solve a challenge or task step by step. In computer
science, it means writing a program that solves a real-life problem using logic and algorithms.
Basic Steps in Problem Solving
1. Understand the Problem
o Read the problem carefully.
o Know what is given (inputs) and what you need to find (outputs).
o Understand any rules or conditions.
2. Break the Problem into Small Parts
o Divide the problem into smaller steps.
o Solve each small part one by one.
3. Plan the Solution
o Think of an algorithm (a list of steps) to solve the problem.
o Example: Use a flowchart or pseudocode.
4. Implement the Solution
o Write the code using a programming language like C, Java, or Python.
o Follow the steps from your algorithm.
5. Test the Solution
o Try the program with sample inputs.
o Check if the output is correct.
o Fix any errors if needed.
6. Improve the Solution
o Make the solution faster or use fewer resources.
o Write clean and understandable code.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 1
What is an Algorithm?
An Algorithm is a step-by-step set of instructions that helps solve a problem or perform a
specific task.
Key Characteristics of an Algorithm
Clear and Unambiguous: Each step must be clear and easy to understand.
Well-Defined Inputs and Outputs: Inputs are what you provide, and outputs are the
results.
Finite Steps: The algorithm should finish after a limited number of steps.
Effective: Each step should be simple enough to execute.
Why Learn Algorithms?
Algorithms are the foundation of programming. Before writing code, we design an
algorithm to solve the problem in a logical way.
It helps in understanding the solution clearly and makes coding easier.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 2
What is a Flowchart?
A Flowchart is a diagrammatic representation of a step-by-step solution of a problem or
process.
It uses standard symbols to represent different types of actions or steps in a process.
Why Use Flowcharts?
Makes the solution easy to understand visually.
Helps plan the logic before coding.
Identifies mistakes in logic early.
Useful for both simple and complex problems.
Common Flowchart Symbols
Oval (Start/End)
Purpose: Indicates the beginning or end of a process.
Example: "Start" or "End"
Rectangle (Process)
Purpose: Represents a process or action step.
Example: "Add two numbers"
Diamond (Decision)
Purpose: Indicates a decision point, leading to different paths based on Yes/No or
True/False.
Example: "Is number > 10?"
Parallelogram (Input/Output)
Purpose: Represents input to or output from a process.
Example: "Display result" or "Enter data"
Arrow (Flow Line)
Purpose: Shows the direction of the flow of the process.
Example: Connecting symbols to indicate sequence.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 3
Advantages of Flowcharts
Easy to understand and communicate.
Helps visualize the process.
Useful for designing programs.
Makes debugging easier.
When to Use a Flowchart
For algorithm design in the initial stage.
When explaining the logic of a program to others.
To break down complex problems into simple steps.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 4
What is Pseudocode?
A Pseudocode is a simple way to design an algorithm using plain English and basic
programming-like statements.
It helps in writing the solution logic step by step before converting it into an actual computer
program.
Why Use Pseudocode?
Helps plan the solution clearly and logically.
Easy to understand, even without knowing a specific programming language.
Helps avoid syntax errors because it is not actual code.
Acts as a bridge between problem understanding and coding.
Key Characteristics of Pseudocode
Written in simple, easy-to-understand English.
No strict syntax rules.
Focuses on logical steps only (no language-specific code).
Uses constructs like IF, WHILE, FOR, INPUT, OUTPUT, etc.
Advantages of Pseudocode
Easy to write and understand.
Helps students focus on the solution logic.
Useful for designing algorithms before programming.
Makes coding easier later on.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 5
Problem: Find the sum of first N natural numbers.
Algorithms:
1. Input a number N.
2. Initialize sum = 0.
3. Loop from 1 to N, adding each number to sum.
4. Print the sum.
Flowchart:
Pseudocode:
Input N
sum = 0
for i = 1 to N
sum = sum + i
End for
Print sum
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 6
Questions
1. Write an algorithm to find the largest number in a list of numbers.
2. Write an algorithm to calculate the factorial of a number.
3. Write an algorithm to check whether a given number is prime or not.
4. Write an algorithm to reverse a number or string.
5. Draw a simple flowchart to find the sum of two numbers.
6. Draw a flowchart to check whether a given number is even or odd.
7. Draw a flowchart to find the largest number among three numbers.
8. Design a flowchart to calculate the factorial of a number.
9. Draw a flowchart to print numbers from 1 to N.
10. Write pseudocode to find the sum of two numbers.
11. Write pseudocode to find the largest of three numbers.
12. Write pseudocode to check whether a number is even or odd.
13. Write pseudocode to calculate the factorial of a number.
14. Write pseudocode to print numbers from 1 to N.
Important Tips
Understand the problem clearly before coding.
Write steps in simple words (pseudocode) before actual coding.
Start by solving simple examples by hand.
Test your program with different inputs.
Keep the code simple and well-organized.
Use print statements to debug and check intermediate results.
2025 B.Tech(Sec- B, D, H, J) – Dr. Brojo Kishore Mishra (bkmishra@nist.edu) Page 7