2015年3月27日星期五

slog of seventh week

This week, the topic we learned about was class  LLNode, to represent linked list nodes, and class LinkedList, to represent an entire linked list. This Node is somewhat similar with the node class we have learnt before. The code of those two class is following:

class LLNode:
    ’’’Node to be used in linked list
    nxt: LLNode -- next node
                   None iff we’re at end of list
    value: object --- data for current node
    ’’’
    def __init__(self, value, nxt=None):
        ’’’ (LLNode, object, LLNode) -> NoneType
        Create LLNode (self) with data value and successor nxt.
        ’’’
        self.value, self.nxt = value, nxt
 class LinkedList:
    ’’’Collection of LLNodes
    front: LLNode -- front of list
    back:  LLNode -- back of list’’’
    def __init__(self):
        ’’’ (LinkedList) -> NoneType
        Create an empty linked list.
        ’’’
        self.front, self.back = None, None
        self.size = 0
The process of LL looks like the process of  bubble sort. We need to use the while loop to control the program to find the node that we want to delete or insert.
We don't have lab this week since the strike. 

没有评论:

发表评论