{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_algorithms_honors - Problem solving vs programming...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem solving vs. programming Problem solving vs. algorithm development vs. programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Problem Solving understand and define the problem what is it that needs to be solved Identify an approach the basic equations, relations, etc Develop and specify an algorithm sequence of steps to be executed specify how data is organized
Background image of page 2
. Evaluate the algorithm always provide correct results ? efficient ? Coding (or Programming)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
. Test and validate Debug program confirm -- gives expected results? confirm efficiency
Background image of page 4
. Documentation problem, its solution, algorithm, program, testing procedure Program maintenance Make necessary changes if errors are found Ensure that it meets user changing requirements
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Problem Understanding and definition Perhaps the most important step Understanding is based on interaction with customer From vague statements to full specification Starts with “develop software that helps me with inventory control” Ultimately develop a problem definition
Background image of page 6
. Input data List of input parameters Parameter type ( Integer, real, character…) Special symbols to indicate end of list, for instance
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
. Output data List of parameters, format, headings, etc. Required processing understand and specify how output is related to input Identify special processing to handle error conditions, corner cases e.g. “list is too long”, “invalid parameter value”
Background image of page 8
Algorithms steps needed to solve the problem Definition of an algorithm an ordered sequence of well-defined and effective operations which, when executed, will terminate in a finite amount of time and produce correct result
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
. Ordered sequence Well-defined and effective Terminate ( always) Produce correct results
Background image of page 10
Correct Result ? Given area of a rectangle A , and one of the sides d , find the other side s . s = A / d Input A, d and get output s If input d= 0, then what happens? Take care in the algorithm itself.
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Well defined?. compute largest prime compute square root of x
Background image of page 12
Termination To find complement of given set of angles Ask for first value of angle A Read the value as entered by user Print 90 – A Repeat for next value of A When does this program terminate?
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Finding Square root Given a number m find n Such that n x n = m Paper-pencil method ?? on computer 3 different ways
Background image of page 14
Algorithm 1 Given m, guess n such that n x n = m If not, try next nearest number Consider m = 70 n lies between 8 and 9 Try 8.5, 8.5 x 8.5 = 72.25 Try between 8 and 8.5 8.2 x 8.2 = 67.24 8.35 x 8.35 = 69.7225 8.37 x 8.37 = 70.0569
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Algorithm 2 or try systematically 8.01, 8.02, ……
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}