AAB - So... What is...? (Lesson)

So... What is?

So... What is the Data?

We have been given directions to a visitor, reviewed directions for sending a message on a cell phone, written pseudocode for a peanut butter and jelly sandwich, and examined at least two peer answers to the PBJ sandwich.  All of these are different scenarios with different ingredients.  So, what do I mean by data?  Data is the ingredients needed to create the solution to the problem presented. 

  1. Visitor Directions Data – street names, place names, location of places for the pertinent question.  Other data located in the map side bar include category data for buy, eat, do, sleep, and contact as well as color for parts of the town.  In this example you are given more data than is needed to answer the question.  Here we learn sometimes there is extraneous items not needed to solve a problem available.
  2. Cell Phone Message Data – security unlock information (finger swipe or code or both), name and/or email address, text message.
  3. Peanut Butter Jelly Sandwich Data – bread, peanut butter, jelly.

Note in each of the above cases, the data is the input to the question to solve the problem. 

The data above did not encompass completely the steps given in the directions for the visitor, cell phone, or the peanut butter and jelly sandwich creation.  Everyone’s directions may have been slightly different to achieve the same goal, but the input data, the data needed was the same.  Whether you took the visitor down through Eugenie Street in Old Town (purple) to visit your favorite eatery, Twin Anchors (red 17) was irrelevant.  This would have been your addition to the discussion, maybe because it was close to lunch time and you thought the visitor might be hungry.  The key was to reach the museum, and there were many ways to do this. 

So... What is the Algorithm?

An algorithm is the steps to solve a problem.  In this case the steps to reach the museum, open and send the cell phone message, or create the peanut butter and jelly sandwich.  The steps to solve the situation presented to you.  A single algorithm may be in use or multiple algorithms. 

Using the visitor directions to go to the Museum:

A.  If you went straight to the museum, no stops along the way, you would have provided one algorithm to get to the museum.  Example:

      1. Go east (straight ahead) on Belden
      2. Turn right on Lincoln Avenue (you might have added the street angles across this one)
      3. Turn right on Clark Avenue (you might have added Lincoln turns slightly left just prior to reaching Clark Avenue and Lincoln Park is now on your left)
      4. When you reach North Avenue the museum is on your left.

B. If you took the scenario above and asked the visitor if they were hungry you could recommend a great eating place along the way, you would have used two algorithms.

  1. Go east (straight ahead) on Belden
  2. Turn right on Lincoln Avenue (you might have added the street angles across this one)
  3. Turn right on Sedgewick Street (you might have added that this is where 3 streets cross, a six point intersection).
  4. Turn left on Eugenie Street and Twin Anchors eatery is on the right (you might have added to try the barbeque ribs and that the restaurant been featured on TV and movies)
    1. When leaving the restaurant, turn right on Eugenie Street
    2. Turn right on Clark Avenue (you might have added Lincoln Park is now on your left)
    3. When you reach North Avenue the museum is on your left.

Using the first set of directions (1), the algorithm is complete with steps a through d.  The portions in the parentheses may have been said but are not required for the directions to work.

Using the second set of directions with the stop for lunch (2), note that the algorithm has a stop in the middle, breaking the directions into two sets, thus two algorithms.  The first algorithm is from the university to Twin Anchors, and the second algorithm is from Twin Anchors to the Chicago History museum.  Again, the portions in the parenthesis’s may have been said but are not required for the directions to work.  The stop in the middle for lunch was an option, if you are hungry here is a great place to eat.

So... What is the Abstraction?

Let’s use our Peanut Butter and Jelly Sandwich problem for this one.  This Peanut Butter and Jelly Sandwich is a recipe to make something to eat.  A recipe is any easy algorithm that we find usually in written form with steps to make something to eat.  In this case I had you write down how to create a Peanut Butter and Jelly Sandwich.

An abstraction is a set of steps that are an algorithm but are set aside, hidden from direct view.  Intuitive is the word used sometimes to mean that is obvious how I would do that.   These are referred to for a specific task. 

In my Peanut Butter and Jelly Sandwich recipe, there are two jars.  The Peanut Butter jar and the Jelly jar.  Both have lids to open.  Think… Do jars open the same way?  Do jars close the same way?  Yes! All jars open the same way and close the same way.  To open you turn left and to close you turn right.  Okay, you might have to jiggle a bit to make sure the lid was on correctly to get turned back to closed.

So… the abstraction to open a jar is:

  1. Grip jar with one hand.
  2. Turn the lid to the left with the other hand until the lid is loose.
  3. Lift the lid off the jar.
  4. Place lid down on the preparation surface.

So… the abstraction to close the jar is:

  1. Grip jar with one hand.
  2. Pick the lid up from the preparation surface, screw side down with the other hand.
  3. Place the lid on top of the jar.
  4. Jiggle lid to fit in the grooves lightly.
  5. Turn the lid to the right until the lid stops turning.

By the way, the above directions to open and close a jar is written in pseudocode,  what needs to happen in steps for the small problem to be solved. We could name the abstractions jarOpen and jarClosed using a programming type of writing called Camel Case.  Note that capitalizing the second work and any subsequent words allows us to read quickly without spaces.

IMAGE CREATED BY GAVS AND USED ACCORDING TO TERMS OF USE.