Algorithms - Algorithms A Little MATLAB Programming Find at...

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

View Full Document Right Arrow Icon
Algorithms + A Little MATLAB 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
( 29 0 2 3 2 = + - = x x x f Methods: 1. Quadratic Formula (analytic) 2. Factorization (analytic) 3. Iteration (algorithmic) Find at least one root of the following function:
Background image of page 2
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
When we solve problems, whether homework or extensive programming assignments a plan of action is needed. Algorithm Etymology: alteration of Middle English algorisme, from Old French & Medieval Latin; Old French, from Medieval Latin algorismus, from Arabic al-khuwArizmi, from al- KhwArizmI fl A.D. 825 Arabian mathematician A procedure for solving a mathematical problem (as of finding the greatest common divisor) in a finite number of steps that frequently involves repetition of an operation; broadly : a step-by-step procedure for solving a problem or accomplishing some end especially by a computer
Background image of page 4
Structured Programs Producing an algorithm for a particular programming problem is a very personal task. Two programmers can arrive equally valid solutions using very different approaches. Fortunately there are some programming/algorithm basic techniques that have been shown to produce efficient solutions. In 1968 Edgar Dijkstra outlined a technique called structured programming. He remarkable idea that algorithms could be constructed from only four types of structures.
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
Sequences of instructions
Background image of page 6
Branches
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
Loops
Background image of page 8
Modules
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
Algorithm Building Structures 1. Sequential – Steps executed one after another in a linear sequence. 2. Selection – Allows for decision processes based on conditional true/false tests. 3. Repetition – Allows parts of algorithm to be repeated. a. Number based – Steps repeated a specific number of times b. Condition based – Steps repeated until a true/false condition becomes false.
Background image of page 10
Actually there are a few more things that are needed to actually produce a working program that implements an algorithm. These are the “nuts and bolts” of any programming language and are specific to that language: Data Operations (add, subtract, compare etc.) Input/Output capability
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
Suppose that we wish to calculate the interest penalty added to an account after a payment is made. There are several steps involved in the solution: 1. Examine the problem to determine what information the problem is requesting. This determines a goal to be achieved. 2. Plan a strategy. Determine equations that are needed in solution. Hierarchy charts can be useful to prepare an overview of the solution. 3. Determine what information in the form of inputs is necessary to effect a solution. Express these inputs in general terms.
Background image of page 12
Interest Calculation Get original balance, rate and payment Calculate new balance Output new balance Apply payment to original balance Calculate interest to be applied Find new balance A hierarchy chart is a useful tool for getting an overview of how parts of an algorithm fit together and interact:
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
Once we have an overview of the problem it is time to work on the algorithm. Algorithm can be expressed in one of a couple of ways: Flowcharts Pseudocode
Background image of page 14
Flowcharts provide a graphical representation of the algorithm. There
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
Image of page 16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 82

Algorithms - Algorithms A Little MATLAB Programming Find at...

This preview shows document pages 1 - 16. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online