2016年2月22日星期一

Week 4 Slog

WeeK 4

This week I learned about stake and queue. I think it is interested. 
I find the following summary about abstract data type online, and find it is really useful:
An Abstract Data Type is a particular kind of class that's defined purely by its interface rather than its implementation - that's what makes itabstract. You're already familiar with three abstract data types:
  • lists: store elements sequentially. Access elements by index, add new elements to the list, determine if the list is empty.
  • dictionaries: store key-value pairs. Look up a value based on key, add/remove key-value pairs.
  • files: objects that you can open for reading in data or for writing data. Start reading from the beginning of a file, starting writing at the beginning of a file, skip to some part of a file.
As you saw in CSC108, you can do many, many useful things with lists and dictionaries - but this power is a double-edged sword. The more operations an interface offers, the harder it is to implement, and to use! This week, we're going to look at a much simpler ADT: the Stack.


stack follows LIFO rule, which is last in first out. Stack is also the place to store the memory. I did the practice of stack and queue. I think the remove part is the hardest part to understand. In the assignment 1, I write about the priority queue. In priority queue the highest item will be remove first.