Algorithms Flowcharts 1 Overview Problem Solving Algorithms Flowcharting
Algorithms & Flowcharts 1
Overview • • Problem Solving Algorithms Flowcharting Value of Perfect Information – Expected Value Table 2
Problem Solving • Informal - have incomplete specification • Formal - have complete specification – initial conditions (Current State) – specified results (Goal State) – specified allowable actions (Action Plan) Problem Solving Formal Informal 3
Five Problem Solving Steps • Define the problem Problem Solving • Generate Potential Solutions • Decide on Alternative Formal Informal • Implement Choice • Evaluate Solution Define Alternatives Decide Implement Evaluate 4
Problem Solving • To solve problems, one must decompose the problem and then recompose a solution. Analysis Synthesis 5
Problem Solution • A well-defined set of specified actions that when enacted, produce a desired result from a set of initial conditions. Initial Conditions Actions Result 6
Problems Have Levels of Solution General Specific • Plan of Action • Strategic Plan • Tactical Action Plan (Algorithm) • Graduate from NKU • Meet Degree Requirements. – Total Credit Hours – GE Requirements – Approved Major • Course of Study – Major courses – Secondary area of study – Culture and Creativity, Individual and Society, Global, Math, Science, Communication, electives 7
Algorithms and Flowcharts • • Ways to think about problems One is textual & one is graphic Describe the flow of logic or decision making Rely on – Explicit directions – Removing redundancy – Goal State (Desired Result) and Current State (Initial Conditions) comparison 8
Algorithm • Defined: finite set of unambiguous instructions, that when given a set of input values, produces the desired outputs, then stops. • Examples: What are some examples of algorithms from everyday life? Think History!? Science!? 9
IPO Chart • Input - Process – Output – Goal State = Output – Current State = Input – Algorithm = Process • Algorithm describes process from current state to goal state – What are other names for algorithms? Inputs Processing Outputs 10
Algorithm Practice • Write an algorithm for getting to school in the morning – Describe “current state’ – Describe “goal state” – Write algorithm • What did you notice about the algorithm? 11
General Algorithm • • • Get up and get dressed If Wednesday, put out trash otherwise go to work Drive to work Review morning calendar If Tuesday or Thursday, review for class Lunch If Tuesday or Thursday, go to class Wrap up days activities Drive home 12
Practice Algorithm • Suppose you have a counter and a stopwatch. You have been asked to count the number of blue cars which go through the roundabout on Nunn Drive within the next hour. • Write an algorithmic solution to this problem. 13
Traffic Counter Thoughts • Initial Conditions • Reset counter • Reset stopwatch • Selective Conditions • Is it blue? • Is it under one hour • Iteration • Each time blue car passes • Assumptions • We all know what “go through” means 14
Algorithm: Notes • • • What level of specificity did you use? What assumptions did you make? Did you have to go back and adjust things? What decisions did you have to make? Were there any contingencies on the decisions? 15
Flowcharts • Show logic of a decision process; • Includes Boolean decision making; • Has standard set of graphical symbols with associated meaning; • Can describe very complex logic if necessary; • Decision Tables can substitute for complex flowcharts in some situations. 16
Flowchart Symbols • Logic Flow • Start or Stop • Process • Interaction • Decision • Connectors 17
Flowchart Rules • • • Actions have one input and one output Terminator have one input OR one output Decisions have one input and TWO output Iterations should loop back to a junction Flowchart logic should run top to bottom and left to right • Label Input-Output • Show direction of logic with arrowheads 18
- Slides: 18