Friday, February 27, 2015

Week7-Thoughts on Abstract Data Type

Abstract Data Type (ADT) is an abstract data type is a model for a particular data structure defined by the methods it can perform. It can be implanted into not only python, but also other programming languages such as java and C++. We learnt three kinds of ADT in CSC148, and I want to introduce them separately.

The most basic form of ADT is stack. Stack allows us to add new items to the top of the stack, then, items are removed from top to bottom. In other works, items are added and deleted based on the rule of “last-in-first-out”. A stack involved three basic operations: push() enables new data to be added, pop() removes the top item, and isEmpty() determines whether everything is removed. The second kind of ADT we learnt is Queue. It is very similar to Stack, but its first added element is removed first. Similarly, A Queue also involved three basic operations: enqueue() enables new data to be added, dequeue() removes the bottom item, and isEmpty() determines whether everything is removed. The third ADT I learned is tree. Like stack and queue, tree also stores data. However, Tree stores data in a hierarchical order. Item in a tree is called node, and bottom nodes that branch out top nodes are children of the top nodes. And nodes without any children(are not parents) are referred as leaves. And finally, the node that the very top is called root.

Tree is the most difficult Abstract Data Type among the three. I also think that it is the key to solve the following assignment, because there are so many variations that can be developed based on it.


No comments:

Post a Comment