Newest Viewed Downloaded

Structured thinking

Structured thinking

Part 1: 1. Introduction 2. Structure Diagram 3. Comparison Part 2: 4. Examples 5. Rules 7. More examples Part 3: 8. Structure - pseudocode 9. Pseudocode - C code 10. End Contents

Structure diagram

Morning routine ”Morningwhile has gold in mouthd” Get dressed Eat breakfast Go to school Time Division A strucure diagram is used to divide a problem or activity into smaller parts. These smaller parts can be divided into even smaller parts, and so on.

Sequence (order in time)

Get dressed Eat breakfast Go to school Morning routine 8:00 am 8:02 am 8:05 am Time Sequence Sequence parts

Structure diagram

”Morningwhile has gold in mouthd” Find clothes Put clothes on Morning routine Get dressed Eat breakfast Go to school Division Time Take from wash basket Ask girlfriend where clothes are At the top you see the activity at its whole. At the bottom you see the same activity in many smaller activities.

Selection

Blue Pink White What colour on your socks? If blue exists If blue doesn’t exist, but pink does Else Selection Selection parts

Structure diagram

”Morningwhile has gold in mouthd” Many glasses of beer One glass of beer Division Time Morning routine Take from wash basket Ask girlfriend where clothes are Find clothes Put clothes on Get dressed Eat breakfast Go to school When you’ve got dressed, it’s time to eat breakfast. Of course, our breakfast in this case consists of ”Many glasses of beer”. In a structure diagram, ”Many glasses of beer” is equal to ”One beer”, performed many times.

Iteration (repetition)

Many glasses of beer One beer Drink beer (lightbeer) As long as you’re thirsty Iteration Iteration part An iteration is a repetition of an event. The iteration ”Many glasses of beer” consists of the iteration part ”One beer”. The iteration part always comes with a condition. As long as the condition is fulfilled, the iteration repeats. The iteration part is marked with an asterisk (*, the computers multiply sign) in the top right corner of the square.

Structure diagram

”Morningwhile has gold in mouthd” Division Time Take a cab Run One step Morning routine Take from wash basket Ask girlfriend where clothes are Find clothes Put clothes on Get dressed Eat breakfast Go to school Many glasses of beer One glass of beer Note that, in this structure diagram, you need to ”Get dressed” before you ”Eat breakfast” and do both before you ”Go to school”.

Flow chart

Move foot one step Run Go to school Eat one pancake Eat breakfast Put on the clothes Ask girl/boyfriend Get from laundry basket Search clothes Get dressed Morning route IF you find basket WHILE pancakes <> 0 Take a cab IF money = 0 ELSE ELSE WHILE distance to school <> 0

Summary

A problem can be divided into a number of smaller problems. When programming, it can sometimes be difficult to know where to start. This is where you use a structure diagram.

The end part 1

Examples Rules More examples Program structure

Crossing

A B Imagine driving in car B, just behind another car A. You come to a crossing. How will you know which direction it will chose? Car A has to make a selection Two cars positioned in a crossing. The car named ”A” has to choose in which direction it want´s to go. How will the car named ”B” know what the car in front of it will do. Let´s make a structure of the problem.

Crossing a selection of directions

How can you see in which direction the car in front of you will choose? Crossing Green signal STOP DRIVE Red signal Left blinker Right blinker No blinker Drive left Straight ahead Drive right Selection The car named ”A” have several choies. The choices is depending on what the crossing allows. If the light turns red (condition =”Red signal”) the car must stop. If the light turns green (condition = ”Green signal”) and car ”A” chooses to turn right it will use right blinker (condition = ”Right blinker”). The following car will know by the condition, that car in front of it will turn right.

Marriage - a selection?

Marry girl Young man´s future choice not JSP In what way can you not construct a selection in a srutucturediagram? A selection must have two selectionparts, choices, or else it´s not a selection. The picture above has only one choice to made. This is not correct.

Selectionparts

Young man´s future choice A selection must contain at least two selection components. If It only contains one there is no selection. Marry girl Be free!! Like this! We see that the same structurediagram now has two selectionparts. It has become a selection. A choice can be made. This is correct.

Al Bundy?

Young man´s future choice We know the end…? Peg.. - make dinner! Marry girl It is however possible to leave a selection component empty. This is another example of how you can construct a selection. There is a choice, but nothing happens in one of the selectionparts.

Example of an iteration

Initiate Input name etc Persons Terminate Label Person * Until name = ”end” Status quo Labels Input name etc Print Label * Until N > 10 Iterations Persons Labels

Rules of Christmas

Checks his slade Santa Claus X-mas day Gives one gift * While gifts not 0 not JSP How can you not construct an iteration? This example has an iterationpart placed in a sequence. This is not correct.

Showing 1 - 20 of 98 items Details

Name: 
f01a-jsp
Author: 
Labsal
Company: 
N/A
Description: 
Structured thinking
Tags: 
equat | input | solv | constant | solut | valu | milk | answer
Created: 
9/29/1998 5:17:50 AM
Slides: 
98
Views: 
23
Downloads: 
1
Rating: 
0


> Comment



Share this presentation
|

Comments

Share this presentation:

|
Sitemap