SlideShare a Scribd company logo
Lecture 03
Problem Solving
CSE115: Computing Concepts
Introduction to Problem Solving
•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.
•Computers can be used to help us solving problems
Software Development Method (SDM)
1. Specification of needs
2. Problem analysis
3. Design and algorithmic representation
4. Implementation
5. Testing and verification
6. Documentation
Specification of Needs
•To understand exactly:
• what the problem is
• what is needed to solve it
• what the solution should provide
• if there are constraints and special conditions.
I want a
train…
Problem Analysis
• In the analysis phase, we should identify the following:
• Inputs to the problem, their form and the input media to be
used
• Outputs expected from the problem, their form and the output
media to be used
• Special constraints or conditions (if any)
• Formulas or equations to be used
Design and Algorithmic Representation
• An algorithm is a sequence of a finite number of steps
arranged in a specific logical order which, when executed,
produces the solution for a problem.
• An algorithm must satisfy these requirements:
• It may have an input(s)
• It must have an output
• It should not be ambiguous (there should not be different
interpretations to it)
• Every step in algorithm must be clear as what it is supposed to
do
Design and Algorithmic Representation
• It must be general (it can be used for different inputs)
• It must be correct and it must solve the problem for which it is
designed
• It must execute and terminate in a finite amount of time
• It must be efficient enough so that it can solve the intended
problem using the resource currently available on the computer
• An algorithm can be represented using pseudocodes or
flowcharts.
Cse115 lecture03problemsolving
Pseudocodes
• A pseudocode is a semiformal, English-like language with limited
vocabulary that can be used to design and describe algorithms.
• Criteria of a good pseudocode:
• Easy to understand, precise and clear
• Gives the correct solution in all cases
• Eventually ends
Pseudocodes: The Sequence control structure
• A series of steps or statements that are executed in the order they
are written in an algorithm.
• The beginning and end of a block of statements can be optionally
marked with the keywords begin and end.
• Example 1:
Begin
Read the birth date from the user.
Calculate the difference between the
birth date and today’s date.
Print the user age.
End
Pseudocodes: The Selection control structure
• Defines two courses of action depending on the outcome of a
condition. A condition is an expression that is, when computed,
evaluated to either true or false.
• The keyword used are if and else.
• Format:
if condition
then-part
else
else-part
end_if
Example:
if age is greater than 55
print “Retire”
else
print “Work Work Work”
end_if
Pseudocodes: The Selection control structure
•Sometimes in certain situation, we may omit the
else-part.
if number is odd number
print “This is an odd number”
end_if
Pseudocodes: The Selection control structure
• Nested selection structure: basic selection structure that
contains other if/else structure in its then-part or else-
part.
if number is equal to 1
print “One”
else if number is equal to 2
print “Two”
else if number is equal to 3
print “Three”
else
print “Other”
end_if
Pseudocodes: The Repetition control structure
• Specifies a block of one or more statements that are repeatedly
executed until a condition is satisfied.
• The keyword used is while.
• Format:
while condition
loop-body
end_while
Pseudocodes: The Repetition control structure
• Example: Summing up 1 to 10
set cumulative sum to 0
set current number to 1
while current number is less or equal to 10
add the cumulative sum to current number
add 1 to current number
end_while
print the value of cumulative sum
Pseudocodes: The Repetition control structure
• Subsequently, we can write the previous pseudocode with
something like this.
• Example: Summing up 10 numbers
cumulative sum = 0
current number = 1
while current number is less or equal to 10
cumulative sum = cumulative sum + current number
current number = current number + 1
end_while
print the value of cumulative sum
• Note that in this algorithm, we are using both the
sequence and repetition control structure
Pseudocodes: The Repetition control structure
• Example:
Begin
number of users giving his birth date = 0
while number of users giving his birth date < 10
Read the birth date from the user.
Calculate the difference between the birth
date and today’s date.
Print the user age.
if the age is greater than 55
print “retire”
else
print “keep working”
end_if
number of user giving his birth date + 1
end_while
End
Flowcharts
• Flowcharts is a graph used to depict or show a step by
step solution using symbols which represent a task.
• The symbols used consist of geometrical shapes that are
connected by flow lines.
• It is an alternative to pseudocoding; whereas a
pseudocode description is verbal, a flowchart is graphical
in nature.
Flowchart Symbols
Terminal symbol - indicates the beginning and
end points of an algorithm.
Process symbol - shows an instruction other than
input, output or selection.
Input-output symbol - shows an input or an output
operation.
Disk storage I/O symbol - indicates input from
or output to disk storage.
Printer output symbol - shows hardcopy printer
output.
Flowchart Symbols cont…
Selection symbol - shows a selection process
for two-way selection.
Off-page connector - provides continuation
of a logical path on another page.
On-page connector - provides continuation
of logical path at another point in the same
page.
Flow lines - indicate the logical sequence of
execution steps in the algorithm.
Flowchart – sequence control structure
Statement 2
Statement 1
Statement 3
:
Flowchart – selection control structure
Condition
else-
statement(s)
then-
statement(s)
YesNo
Flowchart – repetition control structure
Condition
Loop
Statement(s)
yes
no
Flowchart – example 1
Begin
Read birth date
Calculate
Age = current year – birth date
Display
age
End
Flowchart – example 2
Begin
Read age
End
Age > 55? NOYES
print “retired” print “keep working”
Flowchart – example 3
Begin
End
current_number <= 10?
NO
YES
sum = 0
current_number = 1
sum = sum + current_number
current_number = current_number + 1
print sum
Implementation
• The process of implementing an algorithm by writing a
computer program using a programming language (for
example, using C language)
• The output of the program must be the solution of the
intended problem
• The program must not do anything that it is not supposed to
do
• (Think of those many viruses, buffer overflows, trojan horses, etc.
that we experience almost daily. All these result from programs doing
more than they were intended to do)
Testing and Verification
• Program testing is the process of executing a program to
demonstrate its correctness
• Program verification is the process of ensuring that a program
meets user-requirement
• After the program is compiled, we must run the program and
test/verify it with different inputs before the program can be
released to the public or other users (or to the instructor of this
class)
Awesome!!!
Documentation
• Contains details produced at all stages of the program
development cycle.
• Can be done in 2 ways:
• Writing comments between your line of codes
• Creating a separate text file to explain the program
• Important not only for other people to use or modify your
program, but also for you to understand your own program
after a long time (believe me, you will forget the details of your
own program after some time ...)
Documentation
• Documentation is so important because:
• You may return to this program in future to use the whole of or a part
of it again
• Other programmer or end user will need some information about
your program for reference or maintenance
• You may someday have to modify the program, or may discover some
errors or weaknesses in your program
• Although documentation is listed as the last stage of software
development method, it is actually an ongoing process which
should be done from the very beginning of the software
development process.
Homework
• Read the value of the height, width and length of a box from
the user and print its volume.
• Convert temperature (provided as input) from degree Celsius
to degree Fahrenheit.
• Find the minimum of three given numbers.
• Find the maximum of three given numbers.
• Take a, b and c as input and determine the roots for the
equation ax2+bx+c.
• Read a positive integer n from the user and then compute and
print the sum of all integers between 1 and n.
• Read 100 numbers from the user and print their sum.
• Determine whether a given integer is a prime number or not.
• Find the smallest integer n such that, 1+2+3+...+n is equal to
or greater than 1000.
Ad

More Related Content

What's hot (20)

C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
C programming
C programmingC programming
C programming
Harshit Varshney
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
Nico Ludwig
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
jatin batra
 
C++ Tokens
C++ TokensC++ Tokens
C++ Tokens
Amrit Kaur
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
Aami Kakakhel
 
C language programming
C language programmingC language programming
C language programming
Vaibhav Salonia
 
c++
 c++  c++
c++
SindhuVelmukull
 
Basic concept of c++
Basic concept of c++Basic concept of c++
Basic concept of c++
shashikant pabari
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
Ali Aminian
 
Python unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabusPython unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabus
DhivyaSubramaniyam
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
ecko_disasterz
 
Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105
NUST Stuff
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
 
Copy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program designCopy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program design
alish sha
 
C language basics
C language basicsC language basics
C language basics
Milind Deshkar
 
C++ Language
C++ LanguageC++ Language
C++ Language
Syed Zaid Irshad
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 
Unit 2. Elements of C
Unit 2. Elements of CUnit 2. Elements of C
Unit 2. Elements of C
Ashim Lamichhane
 
(2) cpp imperative programming
(2) cpp imperative programming(2) cpp imperative programming
(2) cpp imperative programming
Nico Ludwig
 
C++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer CentreC++ Programming Language Training in Ambala ! Batra Computer Centre
C++ Programming Language Training in Ambala ! Batra Computer Centre
jatin batra
 
C++ PROGRAMMING BASICS
C++ PROGRAMMING BASICSC++ PROGRAMMING BASICS
C++ PROGRAMMING BASICS
Aami Kakakhel
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
Ali Aminian
 
Python unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabusPython unit 2 as per Anna university syllabus
Python unit 2 as per Anna university syllabus
DhivyaSubramaniyam
 
Introduction To Algorithm [2]
Introduction To Algorithm [2]Introduction To Algorithm [2]
Introduction To Algorithm [2]
ecko_disasterz
 
Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105Lecture#2 Computer languages computer system and Programming EC-105
Lecture#2 Computer languages computer system and Programming EC-105
NUST Stuff
 
Introduction to Programming
Introduction to ProgrammingIntroduction to Programming
Introduction to Programming
ALI RAZA
 
Cs1123 3 c++ overview
Cs1123 3 c++ overviewCs1123 3 c++ overview
Cs1123 3 c++ overview
TAlha MAlik
 
Copy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program designCopy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program design
alish sha
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
Aiman Hud
 

Similar to Cse115 lecture03problemsolving (20)

Software develop....
Software develop.... Software develop....
Software develop....
GCWUS
 
Introduction to C ++.pptx
Introduction to C ++.pptxIntroduction to C ++.pptx
Introduction to C ++.pptx
VAIBHAVKADAGANCHI
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptx
Chaya64047
 
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptxs-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
ShamithRai
 
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPTANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
AIET
 
UNIT I.pptxpython unit 1 engineering full unit completed
UNIT  I.pptxpython unit 1 engineering full unit completedUNIT  I.pptxpython unit 1 engineering full unit completed
UNIT I.pptxpython unit 1 engineering full unit completed
pavithrad67
 
Programming Fundamentals - Lecture 1.ppt
Programming Fundamentals - Lecture 1.pptProgramming Fundamentals - Lecture 1.ppt
Programming Fundamentals - Lecture 1.ppt
FarhanGhafoor7
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)
Yogesh Deshpande
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffdPROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
Algorithm week2(technovation)
Algorithm week2(technovation)Algorithm week2(technovation)
Algorithm week2(technovation)
than sare
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
miansaad18
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
DeepikaV81
 
Lecture1
Lecture1Lecture1
Lecture1
Andrew Raj
 
Algorithm.pdf
Algorithm.pdfAlgorithm.pdf
Algorithm.pdf
MIT,Imphal
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
TadiwaMawere
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
Self-Employed
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
Kirti Verma
 
Software develop....
Software develop.... Software develop....
Software develop....
GCWUS
 
Data Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptxData Structures_Introduction to algorithms.pptx
Data Structures_Introduction to algorithms.pptx
RushaliDeshmukh2
 
Pseudo code.pptx
Pseudo code.pptxPseudo code.pptx
Pseudo code.pptx
Chaya64047
 
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptxs-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
s-INTRODUCTION TO PROBLEM SOLVING PPT.pptx
ShamithRai
 
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPTANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
AIET
 
UNIT I.pptxpython unit 1 engineering full unit completed
UNIT  I.pptxpython unit 1 engineering full unit completedUNIT  I.pptxpython unit 1 engineering full unit completed
UNIT I.pptxpython unit 1 engineering full unit completed
pavithrad67
 
Programming Fundamentals - Lecture 1.ppt
Programming Fundamentals - Lecture 1.pptProgramming Fundamentals - Lecture 1.ppt
Programming Fundamentals - Lecture 1.ppt
FarhanGhafoor7
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
Mani Kandan
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)
Yogesh Deshpande
 
C programming for Computing Techniques
C programming for Computing TechniquesC programming for Computing Techniques
C programming for Computing Techniques
Appili Vamsi Krishna
 
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffdPROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
PROGRAMMING IN C UNIT I.pdffffffffffffffffffffffffd
dinesh620610
 
Algorithm week2(technovation)
Algorithm week2(technovation)Algorithm week2(technovation)
Algorithm week2(technovation)
than sare
 
Lec-ProblemSolving.pptx
Lec-ProblemSolving.pptxLec-ProblemSolving.pptx
Lec-ProblemSolving.pptx
miansaad18
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
DeepikaV81
 
Problem-solving and design 1.pptx
Problem-solving and design 1.pptxProblem-solving and design 1.pptx
Problem-solving and design 1.pptx
TadiwaMawere
 
Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
Self-Employed
 
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.pptBCE L-2 Algorithms-and-Flowchart-ppt.ppt
BCE L-2 Algorithms-and-Flowchart-ppt.ppt
Kirti Verma
 
Ad

Recently uploaded (20)

Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
22PCOAM16 ML Unit 3 Full notes PDF & QB.pdf
Guru Nanak Technical Institutions
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
ijdmsjournal
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Working with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to ImplementationWorking with USDOT UTCs: From Conception to Implementation
Working with USDOT UTCs: From Conception to Implementation
Alabama Transportation Assistance Program
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
Lecture - 7 Canals of the topic of the civil engineering
Lecture - 7  Canals of the topic of the civil engineeringLecture - 7  Canals of the topic of the civil engineering
Lecture - 7 Canals of the topic of the civil engineering
MJawadkhan1
 
Artificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptxArtificial intelligence and machine learning.pptx
Artificial intelligence and machine learning.pptx
rakshanatarajan005
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
OPTIMIZING DATA INTEROPERABILITY IN AGILE ORGANIZATIONS: INTEGRATING NONAKA’S...
ijdmsjournal
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdfML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
ML_Unit_V_RDC_ASSOCIATION AND DIMENSIONALITY REDUCTION.pdf
rameshwarchintamani
 
2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt2.3 Genetically Modified Organisms (1).ppt
2.3 Genetically Modified Organisms (1).ppt
rakshaiya16
 
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
01.คุณลักษณะเฉพาะของอุปกรณ์_pagenumber.pdf
PawachMetharattanara
 
Slide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptxSlide share PPT of SOx control technologies.pptx
Slide share PPT of SOx control technologies.pptx
vvsasane
 
Construction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.pptConstruction-Chemicals-For-Waterproofing.ppt
Construction-Chemicals-For-Waterproofing.ppt
ssuser2ffcbc
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
Environment .................................
Environment .................................Environment .................................
Environment .................................
shadyozq9
 
Design of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdfDesign of Variable Depth Single-Span Post.pdf
Design of Variable Depth Single-Span Post.pdf
Kamel Farid
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Ad

Cse115 lecture03problemsolving

  • 2. Introduction to Problem Solving •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. •Computers can be used to help us solving problems
  • 3. Software Development Method (SDM) 1. Specification of needs 2. Problem analysis 3. Design and algorithmic representation 4. Implementation 5. Testing and verification 6. Documentation
  • 4. Specification of Needs •To understand exactly: • what the problem is • what is needed to solve it • what the solution should provide • if there are constraints and special conditions. I want a train…
  • 5. Problem Analysis • In the analysis phase, we should identify the following: • Inputs to the problem, their form and the input media to be used • Outputs expected from the problem, their form and the output media to be used • Special constraints or conditions (if any) • Formulas or equations to be used
  • 6. Design and Algorithmic Representation • An algorithm is a sequence of a finite number of steps arranged in a specific logical order which, when executed, produces the solution for a problem. • An algorithm must satisfy these requirements: • It may have an input(s) • It must have an output • It should not be ambiguous (there should not be different interpretations to it) • Every step in algorithm must be clear as what it is supposed to do
  • 7. Design and Algorithmic Representation • It must be general (it can be used for different inputs) • It must be correct and it must solve the problem for which it is designed • It must execute and terminate in a finite amount of time • It must be efficient enough so that it can solve the intended problem using the resource currently available on the computer • An algorithm can be represented using pseudocodes or flowcharts.
  • 9. Pseudocodes • A pseudocode is a semiformal, English-like language with limited vocabulary that can be used to design and describe algorithms. • Criteria of a good pseudocode: • Easy to understand, precise and clear • Gives the correct solution in all cases • Eventually ends
  • 10. Pseudocodes: The Sequence control structure • A series of steps or statements that are executed in the order they are written in an algorithm. • The beginning and end of a block of statements can be optionally marked with the keywords begin and end. • Example 1: Begin Read the birth date from the user. Calculate the difference between the birth date and today’s date. Print the user age. End
  • 11. Pseudocodes: The Selection control structure • Defines two courses of action depending on the outcome of a condition. A condition is an expression that is, when computed, evaluated to either true or false. • The keyword used are if and else. • Format: if condition then-part else else-part end_if Example: if age is greater than 55 print “Retire” else print “Work Work Work” end_if
  • 12. Pseudocodes: The Selection control structure •Sometimes in certain situation, we may omit the else-part. if number is odd number print “This is an odd number” end_if
  • 13. Pseudocodes: The Selection control structure • Nested selection structure: basic selection structure that contains other if/else structure in its then-part or else- part. if number is equal to 1 print “One” else if number is equal to 2 print “Two” else if number is equal to 3 print “Three” else print “Other” end_if
  • 14. Pseudocodes: The Repetition control structure • Specifies a block of one or more statements that are repeatedly executed until a condition is satisfied. • The keyword used is while. • Format: while condition loop-body end_while
  • 15. Pseudocodes: The Repetition control structure • Example: Summing up 1 to 10 set cumulative sum to 0 set current number to 1 while current number is less or equal to 10 add the cumulative sum to current number add 1 to current number end_while print the value of cumulative sum
  • 16. Pseudocodes: The Repetition control structure • Subsequently, we can write the previous pseudocode with something like this. • Example: Summing up 10 numbers cumulative sum = 0 current number = 1 while current number is less or equal to 10 cumulative sum = cumulative sum + current number current number = current number + 1 end_while print the value of cumulative sum • Note that in this algorithm, we are using both the sequence and repetition control structure
  • 17. Pseudocodes: The Repetition control structure • Example: Begin number of users giving his birth date = 0 while number of users giving his birth date < 10 Read the birth date from the user. Calculate the difference between the birth date and today’s date. Print the user age. if the age is greater than 55 print “retire” else print “keep working” end_if number of user giving his birth date + 1 end_while End
  • 18. Flowcharts • Flowcharts is a graph used to depict or show a step by step solution using symbols which represent a task. • The symbols used consist of geometrical shapes that are connected by flow lines. • It is an alternative to pseudocoding; whereas a pseudocode description is verbal, a flowchart is graphical in nature.
  • 19. Flowchart Symbols Terminal symbol - indicates the beginning and end points of an algorithm. Process symbol - shows an instruction other than input, output or selection. Input-output symbol - shows an input or an output operation. Disk storage I/O symbol - indicates input from or output to disk storage. Printer output symbol - shows hardcopy printer output.
  • 20. Flowchart Symbols cont… Selection symbol - shows a selection process for two-way selection. Off-page connector - provides continuation of a logical path on another page. On-page connector - provides continuation of logical path at another point in the same page. Flow lines - indicate the logical sequence of execution steps in the algorithm.
  • 21. Flowchart – sequence control structure Statement 2 Statement 1 Statement 3 :
  • 22. Flowchart – selection control structure Condition else- statement(s) then- statement(s) YesNo
  • 23. Flowchart – repetition control structure Condition Loop Statement(s) yes no
  • 24. Flowchart – example 1 Begin Read birth date Calculate Age = current year – birth date Display age End
  • 25. Flowchart – example 2 Begin Read age End Age > 55? NOYES print “retired” print “keep working”
  • 26. Flowchart – example 3 Begin End current_number <= 10? NO YES sum = 0 current_number = 1 sum = sum + current_number current_number = current_number + 1 print sum
  • 27. Implementation • The process of implementing an algorithm by writing a computer program using a programming language (for example, using C language) • The output of the program must be the solution of the intended problem • The program must not do anything that it is not supposed to do • (Think of those many viruses, buffer overflows, trojan horses, etc. that we experience almost daily. All these result from programs doing more than they were intended to do)
  • 28. Testing and Verification • Program testing is the process of executing a program to demonstrate its correctness • Program verification is the process of ensuring that a program meets user-requirement • After the program is compiled, we must run the program and test/verify it with different inputs before the program can be released to the public or other users (or to the instructor of this class) Awesome!!!
  • 29. Documentation • Contains details produced at all stages of the program development cycle. • Can be done in 2 ways: • Writing comments between your line of codes • Creating a separate text file to explain the program • Important not only for other people to use or modify your program, but also for you to understand your own program after a long time (believe me, you will forget the details of your own program after some time ...)
  • 30. Documentation • Documentation is so important because: • You may return to this program in future to use the whole of or a part of it again • Other programmer or end user will need some information about your program for reference or maintenance • You may someday have to modify the program, or may discover some errors or weaknesses in your program • Although documentation is listed as the last stage of software development method, it is actually an ongoing process which should be done from the very beginning of the software development process.
  • 31. Homework • Read the value of the height, width and length of a box from the user and print its volume. • Convert temperature (provided as input) from degree Celsius to degree Fahrenheit. • Find the minimum of three given numbers. • Find the maximum of three given numbers. • Take a, b and c as input and determine the roots for the equation ax2+bx+c. • Read a positive integer n from the user and then compute and print the sum of all integers between 1 and n. • Read 100 numbers from the user and print their sum. • Determine whether a given integer is a prime number or not. • Find the smallest integer n such that, 1+2+3+...+n is equal to or greater than 1000.
  翻译: