{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture_algorithms_honors

# lecture_algorithms_honors - Problem solving vs programming...

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

Problem solving vs. programming Problem solving vs. algorithm development vs. programming

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

View Full Document
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
. Evaluate the algorithm always provide correct results ? efficient ? Coding (or Programming)

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

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

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

View Full Document
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
. Input data List of input parameters Parameter type ( Integer, real, character…) Special symbols to indicate end of list, for instance

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

View Full Document
. 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”
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

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

View Full Document
. Ordered sequence Well-defined and effective Terminate ( always) Produce correct results
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.

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

View Full Document
Well defined?. compute largest prime compute square root of x
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?

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

View Full Document
Finding Square root Given a number m find n Such that n x n = m Paper-pencil method ?? on computer 3 different ways
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

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

View Full Document
Algorithm 2 or try systematically 8.01, 8.02, ……
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}