2015年3月1日星期日

Abstract Data Types and recursion

Abstract Data Type is a certain mathematical model for a certain class of  data structures that have similar behavior. (from the definition on the wikipedia) In Professor Danny's class, Danny has described the common ADTs ---- in CS we recycle our intuition about the outside word as ADTs. We abstract the data and operations, and suppress the implementation. And he divides it to three types: 
1. Sequences of items; can be added, removed, accessed by position. 
2. Specialized list where we only have access to most recently added item.  
3. Collection of items accessed by their associated keys.
(from Danny's ppt)
We have discussed several examples in order to understand it. (Stacks, Queues(in lab), Trees etc)
These weeks we are focusing on class Trees. The Tree has children and values and we named the children who has no child leaves. And the BTNode is a binary Tree code which has left children and right children. When it comes to BTNode's leaves, we have the left children and the right children are both equal to None.
And we combine recursion with the class BTNode which is a bit confusing. Let me make an example.
We recall the function list_longest_path itself to solve the problem. We first consider the easiest two conditions and then we extend it to the complicated conditions.






 
 
 
 

没有评论:

发表评论