Understanding Algorithmic Operations & Developing Computer Solutions, Slides of Calculus for Engineers

An introduction to algorithms, their defined sequence of instructions, and the importance of structured programming. It covers the three categories of algorithmic operations: conditional and iterative operations. The document also discusses the advantages of structured programming and the process of developing computer solutions, including effective documentation and the use of structure charts.

Typology: Slides

2012/2013

Uploaded on 03/26/2013

abduu
abduu 🇮🇳

4.4

(49)

195 documents

1 / 38

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Learning Goals
Write MATLAB Programs That can MAKE
“Logical” Decisions that Affect Program
Output
Write Programs that Employ
LOOPing Processes
For → No. Loops know a priori
while → Loop Terminates based on
Logic Criteria
Use the MATLAB DeBugger to
Correct Errors (time permitting)
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26

Partial preview of the text

Download Understanding Algorithmic Operations & Developing Computer Solutions and more Slides Calculus for Engineers in PDF only on Docsity!

Learning Goals

  • Write MATLAB Programs That can MAKE

“Logical” Decisions that Affect Program

Output

  • Write Programs that Employ

LOOPing Processes

  • For → No. Loops know a priori
  • while → Loop Terminates based on Logic Criteria
  • Use the MATLAB DeBugger to

Correct Errors (time permitting)

What’s an “Algorithm”

 A postage stamp issued by the USSR in 1983 to commemorate the 1200th anniversary of Muhammad al-Khowarizmi , after whom algorithms are named.

Algorithmic Operations

1. SEQUENTIAL OPERATIONS →

Instructions executed in order

  1. CONDITIONAL OPERATIONS → Control structures that first ask a question to be answered with a true/false response and then select the next instruction based on the answer
  2. ITERATIVE OPERATIONS (LOOPS): Control structures that repeat the execution of a block of instructions

Structured Programming

• STRUCTURED PROGRAMMING ≡

A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point, and in which control is passed downward through the structure withOUT UNconditional branches to higher levels of the structure. Three types of control flow are used: (1) sequential , (2) test , and (3) iteration.

Structured Program Advantages

  1. Structured programming is effective in a teamwork environment because several people can work on a common program, each person developing one or more modules.
  2. Structured programs are easier to understand and modify , especially if meaningful names are chosen for the modules and if the documentation clearly identifies the module’s task.

Developing Computer Solns

  1. State the problem concisely
    • Use Math Eqns/Relns Whenever possible
  2. Specify the data to be used by the program. This is the “ input .”
    • In physical Problems These are typically
      • Boundary Conditions
      • Initial Conditions
      • Constraints
      • Parameters
  3. Specify the information to be generated by the program. This is the “ output .”

Developing Computer Solns cont

6. Check the output of the program with your hand solution(s)

  1. Run the program with your input data and perform a reality check on the output.
  • Output MUST NOT Violate the Laws of Physics; e.g., in Statics (ENGR36)
  • a CABLE canNOT support NEGATIVE Tension (you can’t PUSH something with a ROPE)
  • Objects canNOT have NEGATIVE Weight or Mass (at least not until we figure out AntiGravity methods)
  • In ENGR43 Physical Resistors, Capacitors, and Inductors can NOT have NEGATIVE Values

Developing Computer Solns cont

  1. If you will use the program as a general tool in the future, test it by running it for a range of reasonable data values;
  • Perform a Reality Check on the results

Anatomy of a Structure Chart Module

the called module

Example: Pizza Pricing Problem

  • Write a program to find the UNIT price for a given pizza. The size of the pizza will be provided in inches. The result must be cost/inch^2

FlowCharting

Example

 Basic House Painting

  • Note the Cascade of Decision-Diamonds

Effective Documentation cont

  1. A verbal description of the program, often in pseudocode.
  • Generic way of describing an algorithm, without use of any specific programming language
  • Helps programmers to PLAN an algorithm
  • Not an actual programming Language, but may borrow syntax from popular programming languages
  • Styles vary

PsuedoCode: Common Terms

  • To Describe input , output , computations , etc., the following terms are often used: - Input: INPUT, READ, GET - Output: PRINT, DISPLAY, SHOW - Compute: COMPUTE, CALCULATE, DETERMINE - Initialize: SET, INIT - Add one: INCREMENT, BUMP, STEP - Decisions: TEST, IF/THEN/ELSE, WHILE/DO

PsuedoCode Algorithms

  • Ensure that the the task is completely specified
  • Issues to Consider
    • What data is known before the program runs?
    • What data must be input by the user?
    • What computations will be performed on the data?
    • What data will be output (displayed) to the user?