AAB - Details of Thinking and Writing (Lesson)
Details of Thinking and Writing
Reflecting on PB & J Directions
Here are some questions to consider now that you have written your peanut butter and jelly sandwich directions! See if you caught the detail needed to have another person that did not know how to make a peanut butter and jelly sandwich actually create the sandwich.
Below are very funny scenarios of what might happen depending on the directions you wrote. See if your directions fit any of these or maybe you see another funny item that could happen depending on how you wrote your directions. If others give you written directions to create the peanut butter and jelly sandwich and then you follow them literally.
Congratulations!!
You have written two algorithms: one for visitor directions and another for a sandwich.
The visitor directions may have been verbal and the visitor in town took quick notes on paper or thought they would remember. Did the visitor make it to their destination? We don't know.
Did the sandwich get made? We do know the answer if we followed the algorithm literally and did not infer steps that were not given. For example, if the peanut butter jar is on the bread, the peanut butter inside the jar was not on the bread, so the sandwich was not edible.
In the peanut butter and jelly scenarios, literally means not making any assumptions or connections that are not there. A computer works with instructions. Step by step - no thought to correct what might be wrong.
How instructions are stated creates choices that a person not understanding must make. We learn by seeing and doing from an early age. Many of the things that we do, we do because we know how and don't think about how to teach someone else. The fact that a bag of bread is to be opened at one end, by undoing a twist tie or clip, infers the process and determines a choice based on current knowledge. Opening the jar of peanut butter seems obvious, but when did we learn that opening the jar meant unscrewing the lid?
Have your family or others give you written directions to create the peanut butter and jelly sandwich or other item and then follow the directions literally, do not infer or add anything to the directions. You will have a fun time if you try to be the machine (computer) that follows literally.
Pseudocode
Looking back, the peanut butter and jelly code had several places that required more specific detail to solve the problem.
Pseudocode has several levels:
- The overall level of a broad plan that may show choices but not the detail for the choices.
- An overall level plan for a choice from the broad plan pseudocode which itself may have choices.
- An overall level plan for a choice from the plan in #2 pseudocode which itself may have choices.
- Continuing until the choice must be solved, the detail as to how to make the lowest choice solved, which then solves the one above, etc. This detail of a problem is the algorithm, the one that determines the answer, yet it will initially be thought and or written in pseudocode and then translated to the math or computer language to make the solution possible.
Pseudocode allows a plan to be sketched out at multiple levels prior to allowing a big problem to be broken down into smaller problems which can then be solved efficiently and checked for accuracy. The key with pseudocode is understanding that it is a blueprint, the plan from which the fine detail can be handled in small enough parts. The smaller parts allow multiple people to work on the project, each handling theirs.
Everyone knows the overall plan and then the pieces are tested individually and then inserted into the plan. Once in the plan the flow must again be evaluated to check for a missing piece of understanding. Modifications may then be made as the plan is tested, just like you would have liked to do with the jar of peanut butter.
In your pseudocode, direction was needed if you did not tell the person, acting as a computer, how to open the jar. A computer program only does what the human coding tells the program, to execute. Without instructions for all cases, the computer could get lost and do something wrong. So here are some basic pseudocode instructions:
To open the jar of peanut butter, hold the body of the jar with one hand and twist the lid to the left, lifting the lid off of the jar when it is loose.
Read the following pseudocode to send a message on a cell phone. Notice the level of instruction, directions, and choices. This pseudocode has branching instructions. See if you can find them. Does it match exactly your phone or is a special branch needed for your phone, a new choice option?
The cell phone pseudocode that you read through did not specify which type or model of cell phone. Are all cell phones alike? No.
This is an example of pseudocode that describes the plan, the overall scenario, but not the extreme detail that would be needed in every step. Sometimes an attempt at the logic that would be needed in the algorithm solution to a single portion is described, sometimes not. Some steps may require knowing more about the specific phone. Could you follow the steps with your cell phone? What needed fixing? Are more choices needed?
Are all android phones alike? No, so in some steps I must create branching. Did you find the statements if and if-else? These are branches that could lead to a small specific algorithm specifically written for the branch.
An algorithm is a series of steps to solve a particular problem and is specific to that situation only. There may be many algorithms within a program to solve all sorts of small problems that together lead to the solution of the complete problem which is the big picture of what the program was to accomplish.
Pseudocode of a program is more generic and broad than the pseudocode written for a specific smaller problem within the program.
For example: An algorithm may be contained within the main section of the program and is the control feature and another algorithm may be off to the side, only called to be used when you want a character in your code to jump a certain way or a certain number of times. Both are algorithms used to complete the whole program. Both can have pseudocode written for them to map out what would need to be included to make each individual algorithm work.
IMAGE CREATED BY GAVS AND USED ACCORDING TO TERMS OF USE.