2015年3月29日星期日

Week11 SLOG: Wrong understanding on Linked List

After revisiting week 8 and week 9 SLOGs, I found I made something wrong with Linked List. In these two SLOGs, I defined some concepts about Tree and Linked List and wrote some functions about them. However, I did not understand the concept about Linked List clearly because I did not consider Linked List as one kind of Tree Type.

First of all, I need to review definition of Linked List and Tree to prove what I made wrong with Linked List. Firstly, a Tree is a set of nodes with directed edges between some pair of nodes and an edge connects a parent node and a child node. Secondly, a Linked List is a linear sequence of nodes and we will keep a reference to the front of the sequence. In conclusion, Linked List can be considered as a tree like this (assuming Linked List has 6 nodes in this Tree):

 16
 
 15
 
 14
 
 13
 
 12
 
 11


Each height of the tree only contains one node, and it is the maximum height that a tree can have. In addition, there is only one path that the tree has, which likes a linear sequence. Overall, Linked List is a type of tree.

没有评论:

发表评论