lecture05-jan30 - EE312 - Lecture 5 Announcements...

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

View Full Document Right Arrow Icon
EE312 - Lecture 5 Announcements • Assignment 1 due today before midnight • Assignment 2 out next week • Topics for today will address: – algorithms – conditionals in decision making statements Program control logic • More complex problems require the ability of a program to contain situational decision logic that provides for alternative paths of execution: 1. Instructions done in sequence (what we have seen so far) can be grouped 2. Selection among alternative paths of execution 3. Iteration/repetition of a set of instructions • C has several types of statements for implementing these capabilities • But first we need to understand these at the program design level Introduction to Problem Solving and Algorithms Programs are made of Algorithms (implemented as functions in C) and Data Structures (implemented as variables, arrays, etc.) What is an Algorithm? An algorithm is a procedure (i.e. a sequence of steps/instructions) for solving a given problem. It must be correct, complete, unambiguous, terminating, capable of being “executed”(by the execution agent) and understandable. • A given problem may be solvable by a number of different algorithms. Its importance is crucial in figuring out a solution procedure. • An algorithm may be transformed into a working program if its computable • An algorithm will typically use levels of abstraction to make the solution clearer and implementation easier. • An algorithm may be represented in several ways: Pseudocode - structured English language used to help design an algorithm (free form; e.g. recipe) Flowchart - a graphical representation of an algorithm. It shows control and data flow. Formal languages - outside the scope of this course How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: Found on the back of a shampoo bottle - circa 1965 How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: Steps 1 - 4 depict a sequential flow of instructions Step 5 introduces the notion of repetition/iteration of instructions
Background image of page 1

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

View Full DocumentRight Arrow Icon
How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat Follow these simple steps: 0) If out of shampoo, then run out and buy some This is a decision making statement How To Shampoo Your Hair 1) Wet your hair 2) Apply shampoo 3) Lather 4) Rinse 5) Repeat steps 1 - 4, if necessary Follow these simple steps: This is a bounded iteration statement How To Shampoo Your Hair 1) Wet your hair 2) Set the wash hair counter to 0 3) Repeat steps 3A - 3D while the value of wash hair counter is less than
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2010 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas at Austin.

Page1 / 5

lecture05-jan30 - EE312 - Lecture 5 Announcements...

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

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