0% found this document useful (0 votes)
55 views

Unit - I

The document provides information about problem solving methodology and programming. It discusses the problem solving process which involves transforming a problem description into a solution. It outlines the typical steps taken to develop a programming language which are: defining the problem, analysis and feasibility analysis, designing a solution through algorithms, coding, testing, and implementation. It also discusses tools used in problem solving and programming like algorithms, flowcharts, and pseudocode. Examples of algorithms for various problems are provided along with corresponding flowcharts. The differences between algorithms and flowcharts are highlighted.

Uploaded by

Nishita Pandey
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)
55 views

Unit - I

The document provides information about problem solving methodology and programming. It discusses the problem solving process which involves transforming a problem description into a solution. It outlines the typical steps taken to develop a programming language which are: defining the problem, analysis and feasibility analysis, designing a solution through algorithms, coding, testing, and implementation. It also discusses tools used in problem solving and programming like algorithms, flowcharts, and pseudocode. Examples of algorithms for various problems are provided along with corresponding flowcharts. The differences between algorithms and flowcharts are highlighted.

Uploaded by

Nishita Pandey
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
You are on page 1/ 32

MEDI-CAPS UNIVERSITY, INDORE

FACULTY OF SCIENCE
DEPARTMENT OF COMPUTER SCIENCE

CA3CO01
PROBLEM SOLVING AND PROGRAMMING

Unit-I
Problem Solving Methodology
BOOKS TO BE REFERRED

• Text Books
1. R.G. Dromey, How to Solve it by Computer, Pearson Education
2. B.W. Kernighan and D. M. Ritchie, The C Programming Language, Pearson Education.
3. B. Gottfried, Programming with C , 2nd Edition, (Indian Adapted Edition), TMH .

• References Books
1. H. Schildt C, The Complete Reference, Tata McGraw Hill.
2. E. Balaguruswamy, Programming in C, Tata McGraw Hill.
3. Y. Kanetkar, Let us C, BPB Publications.
4. Practical C Programming, 3rd Edition, A Nutshell Handbook O’Relly.
5. A. N Kamthaneet. al, Computer Programming and IT, Pearson Education, 2011.
Programming is a problem solving activity. When you write a program, you
are actually writing an instruction for the computer to solve something for
you.

Problem solving is the process of transforming the description of a problem

into a solution by using our knowledge of the problem domain and by relying
on our ability to select and use appropriate problem-solving strategies,

techniques and tools.


PROBLEM SOLVING PROCESS INVOLVES

MANUAL WORKING ------------------------- Computerized Process (Automation Process)


STEPS TO DEVELOPMENT OF PROGRAM
Development of programming language is entirely dependent on the kind of problem and requirement.
However, development of a programming language normally (not essentially, but) includes the following
steps :

Defining the Problem


Analysis and Feasibility Analysis
Design a Solution : Development and Verification of Algorithm
Coding
Testing and Documentation
Implementation
PROBLEM STATEMENT / DEFINING THE PROBLEM
Problem solving is the act of defining a problem; determining the cause of the problem; identifying, prioritizing, and
selecting alternatives for a solution; and implementing a solution.

An effective problem solver will take the opinions of everyone involved into account.

“What are the current problems?” This stage


means getting input from all stakeholders, including
customers, salespeople, industry experts, and
programmers.
One should know the strengths and weaknesses of
the current system with improvement as the goal.
PROBLEM STATEMENT / DEFINING THE PROBLEM

The problem-solving steps support the involvement of interested parties, the use of factual information, comparison of
expectations to reality, and a focus on root causes of a problem.

It should begin by:


• Reviewing and documenting how processes currently work (i.e., who does what, with what information, using what tools,
communicating with what organizations and individuals, in what time frame, using what format).
• Evaluating the possible impact of new tools and revised policies in the development of your "what should be" model.
• Problem-solving techniques include using flowcharts to identify the expected steps of a process and cause-and-effect
diagrams to define and analyze root causes.
ANALYSIS
The main objectives of analysis are – To identify the deficiencies in the current system. To determine objectives of
the proposed system. To acquire a sense of scope of the system. To identify the responsible users. To determine
whether it is feasible to develop the new system.

Types of Analysis are:

1. Financial Analysis
2. Time Limit Analysis
3. Technical Analysis and
4. Operational Analysis
DESIGN A SOLUTION

A design defines all the architectural modules of the product along with its communication and data flow
representation with the external and internal modules. The external and internal design should be clearly
defined in Data Definition Document.

Design is of two types

Logical Design Physical Design


TEST THE SOLUTION

Once the design process is successfully done. Then comes the testing phase. Testers test
the well defined codes written during Design Process and they intend to find the bugs in it.
Successful testing defines the error-free codes.

Testing is of two types

Alpha (α) Testing Beta (β) Testing


IMPLEMENT AND MAINTENANCE OF CODING

Once the product is tested and results successfully then it is ready to be deployed. It is released
formally to the customer. Sometimes product deployment happens in stages as per the business strategy
of that organization. The product may first be released in a limited segment and tested in the real
business environment - Beta (β) testing). After based on the results of Beta Testing and feedback, the
product may be released as it is or with suggested enhancements in the targeting market segment.

Then

After the product is released in the market, its maintenance is done for the existing customer base.
DESIGN TOOLS

• Algorithm

• Flowchart

• Coding
ALGORITHM
An algorithm is a step-by-step method for solving a problem. An algorithm refers to a set of instructions that define
the execution of work to get the expected results. To make the program work properly, we must have to properly
design the algorithm. Designing the algorithm helps to utilize the computing resources effectively.
Before solving a problem, one should know what to do, how to do it, and what types of steps should be taken.
The algorithms are written in natural language or in plain English language. We can represent algorithms
via flowcharts, pseudo code, and others..
Algorithm is a proper technique that illustrates the right solution in logical and feasible steps. Algorithm is normally
done in the form of flowcharts and pseudo codes.

Advantages of algorithm Disadvantages of algorithm

•Algorithms are easy to write. •Algorithms are difficult to debug.


•There is a use of human-readable techniques to •It is hard to show branches and loops using an algorithm.
understand logic.
•For big problems, algorithms can be written with •Jumping (or goto statements) makes the algorithm hard to trace
moderate steps. the problems.
Types of algorithm

•Recursive algorithms.

•Dynamic programming algorithm.
•Backtracking algorithm.

•Divide and conquer algorithm.

•Greedy algorithm.

•Brute Force algorithm.
Example: Write an algorithm to prepare a cup of tea.
Example: Write an algorithm to print the numbers from 1 to 20.

Step 1: Initialize a variable 'x' as 0,

Step 2: Increment the variable 'x' by 1,


Step 3: Print the variable 'x’
Step 4: If 'x' is less than 20, then go back to step 2. Otherwise, go to
the next step.

Step 5: Exit.
Example: The Algorithm to Find the sum two numbers N and M

Step 1: Enter the two numbers in the variables N and M.

Step 2: Sum them and save the result in the variable sum.

Step 3: Output the result.


Example: Write an algorithm to print the numbers from 1 to 20.
Algorithm:

Step 1: x = 0,
Step 2: x = x + 1
Step 3: Print x
Step 4: If ‘x < 20,

then go back to step 2.

else, go to the next step.


Step 5: Exit.
Algorithm to
Convert Temperature from Fahrenheit (℉) to Celsius (℃)

Step 1: Read temperature in Fahrenheit.

Step 2: Calculate temperature with formula C=5/9*(F-32).


Step 3: Print C.
FLOWCHART

• The Flowchart is graphical representation of an algorithm and procedural design


workflows.
• It uses various symbols to show the operations and decisions to be followed in a
program.
• It flows in sequential order.
• For Example, a parallelogram in the flowchart may be used to indicate input and
output, a rectangular box indicates a mathematical operation, a diamond symbol
indicates the decision-making statements, and several other symbols are used in
flowcharts.
Advantages of Flowchart Disadvantages of Flowchart

•Proper debugging
•Effective analysis •Time-consuming
•Efficient coding •Complex
•Proper documentation •Difficult to modify
•Efficient program maintenance •It has no standard
Major
Symbols
Used
In
Flowchart
Symbols
Used
In
Flowchart
Three Most Commonly Used Types of Flowcharts

•Process Flowchart

•Data Flowchart

•Business Process Modeling Diagram


Flowchart to
Convert Temperature from Fahrenheit (℉) to Celsius (℃)
Algorithm to:
Determine Whether A Student Passed the Exam or Not:

•Step 1: Input grades of 4 courses M1, M2, M3 and M4,

•Step 2: Calculate the average grade with formula "Grade=(M1+M2+M3+M4)/4“


•Step 3: If the average grade is less than 60, print "FAIL", else print "PASS".
Flowchart to:
Determine Whether A Student Passed the Exam or Not:
Flowchart to:
Determine the average of 3 numbers………
Difference
between
Algorithm
and
flowchart
PSEUDO - CODE
Pseudo code is a term which is often used in programming and algorithm based fields. It is a methodology that allows the
programmer to represent the implementation of an algorithm. Simply, we can say that it’s the cooked up representation of
an algorithm. Often at times, algorithms are represented with the help of pseudo codes as they can be interpreted by
programmers no matter what their programming background or knowledge is. Pseudo code, as the name suggests, is a
false code or a representation of code which can be understood by even a layman with some school level programming
knowledge.
Algorithm: It’s an organized logical sequence of the actions or the approach towards a particular problem. A programmer
implements an algorithm to solve a problem. Algorithms are expressed using natural verbal but somewhat technical
annotations.
Pseudo code: It’s simply an implementation of an algorithm in the form of annotations and informative text written in plain
English. It has no syntax like any of the programming language and thus can’t be compiled or interpreted by the computer.
Advantages of Pseudocode

•Improves the readability of any approach. It’s one of the best approaches to start implementation of an algorithm.

•Acts as a bridge between the program and the algorithm or flowchart. Also works as a rough documentation, so the
program of one developer can be understood easily when a pseudo code is written out. In industries, the approach of
documentation is essential. And that’s where a pseudo-code proves vital.

•The main goal of a pseudo code is to explain what exactly each line of a program should do, hence making the code
construction phase easier for the programmer.

You might also like