Thursday 26 February 2015

Week 7: Summary of Abstract Data Types (ADTs)

Hello,

A new concept that I have been introduced to this year was abstract data types. I never thought that these data types would exist. I thought that most programming data was just held in the common int, str, list and dict. But after learning more about these data types I learned that they added more functionality to accessing data, searching through data and writing data. The types of ADTs we learned so far are:

Stacks:
I like the title stacks because it describes how the data type works. New stacks can only be added from the 'top' and data can only be read from the 'top'. What helped me understand this data type is thinking of stacking rocks. If you want to add data to this stack then you cant add a rock to the bottom because the tower is going to collapse, so you add it to the top of the stack. Same if you wanted to take a rock off of the stack and examine it, you can only take it off of the top to examine so the tower does not collapse.


Queue:
A queue is a little different from a stack. What helped me understand this data type is thinking of a line up at a restaurant. If you wanted to add some data to this "line up" then you cannot add it right at the front of the queue (unless it is empty) because you will be cutting in line. If you wanted to read data from a queue then you take from the "front" of the line and not from the back because the data at the front of the line has been waiting there.


Tree:
A tree is quite unique in that it contains nodes that store data but has "children" that are also nodes that store data and could have children as well. Just from seeing this you can tell trees have a recursive design to them. That trees contain smaller trees that contain smaller trees. So you can see if you would like to access data in a tree recursion could used to run through the similar nodes of a tree. What helps me think of a tree is a an upside down tree that branches out with its nodes that contain data types. If a node does not have any children than it can be called a leaf.


Binary Tree:
This is similar to the tree. The only difference is that nodes in this tree have up to and including 2 children only. This tree can be much more useful when holding data such as arithmetic operators that have children of numbers that they want to use the operators on since you addition, multiplication, subtraction and division take two inputs.


I hope you understand my interpretation of these ADTs well, and that they were not to confusing. I am sure the learning ADTs they will help me a lot more in the future when working on several projects on methods of storing data.

Thanks for reading,
Rod Mazloomi

1 comment:

  1. Hi there,

    Great blog post. I definitely thought the same way with ADTs-- I'm sure they are we will be exposed to later down the road.

    ReplyDelete