0% found this document useful (0 votes)
2 views26 pages

Problem Solving and Programming Guide

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views26 pages

Problem Solving and Programming Guide

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Problem

Solving and Programming


Unit-1

05-02-2025 Developed by Dr Sandeep Monga 1


Problem-Solving Aspect
• The problem-solving aspect refers to the ability to identify, analyze,
and resolve issues effectively and efficiently. It involves using logic,
creativity, and critical thinking to find solutions that are practical and
beneficial. Key components include:
1. Problem Identification
2. Analysis and Research
3. Generating Solutions
4. Implementation
5. Evaluation

05-02-2025 Developed by Dr Sandeep Monga 2


1. Problem Identification
• Clearly understand and define the problem.
• Differentiate between symptoms and root causes.
• Use tools like the 5 Whys or Fishbone Diagrams to dig deeper.

2. Analysis and Research


• Gather all relevant data and information.
• Use techniques like SWOT (Strengths, Weaknesses, Opportunities,
Threats) analysis or statistical methods to evaluate the situation.

05-02-2025 Developed by Dr Sandeep Monga 3


3. Generating Solutions
• Brainstorm multiple potential solutions.
• Evaluate these solutions for feasibility, cost, impact, and time
required.
• Use frameworks like Decision Matrix to prioritize options.
4. Implementation
• Develop a clear action plan with timelines and responsibilities.
• Communicate the plan to all stakeholders.
5. Evaluation
• Monitor the outcomes and compare them with the expected results.
• Adjust strategies if necessary and learn from successes or failures.

05-02-2025 Developed by Dr Sandeep Monga 4


Practical Skills for Problem-Solving:
• Critical Thinking: Assess situations from multiple perspectives.
• Collaboration: Work effectively in teams for diverse insights.
• Creativity: Innovate new and unconventional solutions.
• Technical Skills: Use domain-specific knowledge or tools.
• Communication: Convey findings and action plans effectively.

05-02-2025 Developed by Dr Sandeep Monga 5


Top-Down Design Approach
• Top-Down Design is a systematic approach to problem-solving and
design where a problem or system is broken down into smaller, more
manageable components. This hierarchical approach starts with a
high-level overview and proceeds by progressively refining the system
into detailed components. It's widely used in software development,
project management, and engineering.

05-02-2025 Developed by Dr Sandeep Monga 6


Key Features of Top-Down Design
[Link]-Level Perspective: Begin with the overall purpose or function.
[Link]: Break down the problem into smaller sub-problems
or modules.
[Link] on Abstraction: Address broader functionalities first before
diving into specifics.
[Link] Refinement: Refine each module iteratively until the entire
system is well-defined.

05-02-2025 Developed by Dr Sandeep Monga 7


Steps in Top-Down Design
[Link] the Problem:
1. Clearly articulate the main goal or functionality of the system.
2. Example: For a library management system, the high-level goal might be
"Manage library operations."
[Link] into Subsystems:
1. Identify major components or modules that contribute to the overall goal.
2. Example: "Book Inventory," "User Management," "Transaction
Management."

05-02-2025 Developed by Dr Sandeep Monga 8


3. Refine Each Subsystem:
1. Break down subsystems into smaller, detailed tasks or components.
2. Example: "Book Inventory" could include "Add Book," "Remove Book," and
"Search Book."
4. Implement and Test:
1. Develop and test each module individually.
2. Integrate modules to ensure they work together as intended.

05-02-2025 Developed by Dr Sandeep Monga 9


Applications of Top-Down Design
• Software Development:
• Used in designing algorithms, applications, or systems.
• Example: Breaking an e-commerce website into "User Interface," "Database
Management," and "Payment Processing."
• Project Management:
• Define project goals and decompose them into milestones and tasks.
• Education:
• Create curricula by starting with broad learning objectives and refining into
specific lessons.

05-02-2025 Developed by Dr Sandeep Monga 10


Advantages
• Clarity: Ensures the overall purpose is always in focus.
• Modularity: Promotes reusable and independent components.
• Scalability: Facilitates future expansions or modifications.
Disadvantages
• Dependency on Initial Design: Errors in the top-level design can
cascade.
• Rigid Structure: May not accommodate changing requirements easily.

05-02-2025 Developed by Dr Sandeep Monga 11


What is Algorithm ?
• A set of sequential steps usually written in Ordinary Language to solve a
given problem is called Algorithm.
• It may be possible to solve to problem in more than one ways, resulting in
more than one algorithm.
• The choice of various algorithms depends on the factors like reliability,
accuracy and easy to modify.
• The most important factor in the choice of algorithm is the time
requirement to execute it, after writing code in High-level language with
the help of a computer.
• The algorithm which will need the least time when executed is considered
the best

05-02-2025 Developed by Dr Sandeep Monga 12


Steps involved in algorithm development
• An algorithm can be defined as “a complete, unambiguous, finite
number of logical steps for solving a specific problem “
• Step1. Identification of input: For an algorithm, there are quantities
to be supplied called input and these are fed externally. The input is
to be identified first for any specified problem.
• Step2: Identification of output: From an algorithm, at least one
quantity is produced, called for any specified problem.
• Step3 : Identification the processing operations : All the calculations
to be performed in order to lead to output from the input are to be
identified in an orderly manner.

05-02-2025 Developed by Dr Sandeep Monga 13


• Step 4 : Processing Definiteness : The instructions composing the
algorithm must be clear and there should not be any ambiguity in
them.
• Step 5 : Processing Finiteness : If we go through the algorithm, then
for all cases, the algorithm should terminate after a finite number of
steps.
• Step 6 : Possessing Effectiveness : The instructions in the algorithm
must be sufficiently basic and in practice they can be carries out easily

05-02-2025 Developed by Dr Sandeep Monga 14


An algorithm must possess the following
properties
1. Finiteness: An algorithm must terminate in a finite number of steps
2. Definiteness: Each step of the algorithm must be precisely and
unambiguously stated
3. Effectiveness: Each step must be effective, in the sense that it should be
primitive easily convert able into program statement) can be performed
exactly in a finite amount of time.
4. Generality: The algorithm must be complete in itself so that it can be used
to solve problems of a specific type for any input data.
5. Input/output: Each algorithm must take zero, one or more quantities as
input data produce one or more output values. An algorithm can be written
in English like sentences or in any standard representation sometimes,
algorithm written in English like languages are called Pseudo Code

05-02-2025 Developed by Dr Sandeep Monga 15


Example Suppose we want to write an algorithm
to find the average of three numbers
Step 1 Read the numbers a, b, c
Step 2 Compute the sum of a, b and c
Step 3 Divide the sum by 3
Step 4 Store the result in variable d
Step 5 Print the value of d
Step 6 End of the program

05-02-2025 Developed by Dr Sandeep Monga 16


Write an algorithm to calculate the simple interest
using the formula. Simple interest = P*N* R/100
Where P is principal Amount, N is the number of years and R is
the rate of interest

Step 1: Read the three input quantities’ P, N and R.


Step 2 : Calculate simple interest as Simple interest = P* N* R/100
Step 3: Print simple interest.
Step 4: Stop

05-02-2025 Developed by Dr Sandeep Monga 17


Write an algorithm to find the area of the triangle.
Let b, c be the sides of the triangle ABC and A the
included angle between the given sides.
• Step 1: Input the given elements of the triangle namely sides
b, c and angle between the sides A.
• Step 2: Area = (1/2) *b*C* sin A
• Step 3: Output the Area
• Step 4: Stop

05-02-2025 Developed by Dr Sandeep Monga 18


Write an algorithm to find the largest of three
numbers X, Y,Z.
• Step 1: Read the numbers X,Y,Z.
• Step 2: if (X > Y)
MAX = X
else
MAX = Y
Step 3 : if (MAX < Z)
Step 4: MAX = Z
Step 5: Print the largest number i.e. MAX
Step 6: Stop
05-02-2025 Developed by Dr Sandeep Monga 19
Write algorithm to find the factorial of a given
number N
• Step 1: Fact = 1
• Step 2: I = 0
• Step 3: read N
• Step 4: While I < N
do
I=I+1
Fact =Fact* I
Step 5: Write “Factorial of”, N, “is”, Fact
Step 6: Stop

05-02-2025 Developed by Dr Sandeep Monga 20


Implementation of Algorithm
• FlowChart
• Psuedo Code
• Programming Code in any language like
C
C++
Java
Python

05-02-2025 Developed by Dr Sandeep Monga 21


What is Flow Chart ?
• A flow chart is a step-by-step diagrammatic representation of the
logic paths to solve a given problem. Or A flowchart is visual or
graphical representation of an algorithm.
• The flowcharts are pictorial representation of the methods to be used
to solve a given problem and help a great deal to analyze the problem
and plan its solution in a systematic and orderly manner.
• A flowchart when translated in to a proper computer language,
results in a complete program

05-02-2025 Developed by Dr Sandeep Monga 22


Advantages of Flowcharts
1. The flowchart shows the logic of a problem displayed in pictorial
fashion which felicitates easier checking of an algorithm.
2. The Flowchart is good means of communication to other users. It is
also a compact means of recording an algorithm solution to a problem.
3. The flowchart allows the problem solver to break the problem into
parts. These parts can be connected to make master chart.
4. The flowchart is a permanent record of the solution which can be
consulted at a later time

05-02-2025 Developed by Dr Sandeep Monga 23


Difference between Algorithm and Flowchart
Algorithm Flow Chart
1. A method of representing the step-by-step 1. Flowchart is diagrammatic representation of an
logical procedure for solving a problem algorithm. It is constructed using different types
of boxes and symbols.

2. It contains step-by-step English descriptions, 2. The flowchart employs a series of blocks and
each step representing a particular operation arrows, each of which represents a particular step
leading to solution of problem in an algorithm

3. These are particularly useful for small problems 3. These are useful for detailed representations of
complicated programs

4. For complex programs, algorithms prove to be 4. For complex programs, Flowcharts prove to be
Inadequate adequate

05-02-2025 Developed by Dr Sandeep Monga 24


Symbols used in Flow-Charts
• The symbols that we make use while drawing flowcharts as given
below are as per conventions followed by International Standard
Organization (ISO).
i) Oval: Rectangle with rounded sides is used to indicate either
START/ STOP of the program. ..

ii) b. Input and output indicators: Parallelograms are used to


represent input and output operations. Statements like INPUT,
READ and PRINT are represented in these Parallelograms

05-02-2025 Developed by Dr Sandeep Monga 25


• Process Indicators: - Rectangle is used to indicate any set of
processing operation such as for storing arithmetic operations

• d. Decision Makers: The diamond is used for indicating the step of


decision making and therefore known as decision box. Decision boxes
are used to test the conditions or ask questions and depending upon
the answers, the appropriate actions are taken by the computer. The
decision box symbol is

• e. Flow Lines: Flow lines indicate the direction being followed in the
flowchart. In a Flowchart, every line must have an arrow on it to
indicate the direction. The arrows may be in any direction

05-02-2025 Developed by Dr Sandeep Monga 26

You might also like