알파카징징이 알파카징징이 코딩하는 알파카

데이터 구조 및 분석 ch_3_3 Linked List I

» writing

KAIST 산업및시스템공학과 문일철_ 데이터 구조 및 분석 수업을 참고하여 작성하였습니다

ch_3_3 Linked List I

정의


Linked List I

1. Assignment and Equivalence
    : One variable's value is changed
    : == checks the equivalence of two referenced values
    : is checks the equivalence of two referenced objects's IDs

2. Basic structure : singly linked list
    : construct a singly linked list with nodes and reference
    : A node consists of
        - A variable to hold a reference to its next node
        - A variable to hold a reference to ist value object
    : Special nodes Heand and Tail
        - You can construct the singly linked list without them
        - But, using them makes serach, insert and delete more convenient
    : Generally, requires more coding than array

3. Implementation of Node class
    : Member variables
        - variable to reference the next node
        - variable to hold a value object
        - variable to check whether it is a head or not
        - variable to check whether it is a tail or not
    : Member functions
        - various set/get methods
class Node :
    nodeNext = ''
    objValue = ''
    binHead = False
    binTail = False
    def __init__(self, objValue = '', nodeNext = '',binHead = False, binTail = False):
        self.nodeNext = nodeNext
        self.objValue = objValue
        self.binHead = binHead
        self.binTail = binTail
    def getValue(self):
        return self.objValue
    def setValue(self, objValue):
        self.objValue = objValue
    def getNext(self):
        return self.nodeNext
    def setNext(self, nodeNext):
        self.nodeNext = nodeNext
    def isHead(self):
        return self.binHead
    def isTail(self):
        return self.binTail

node1 = Node(objValue='a')
nodeTail = Node(binTail = True)
nodeHead = Node(binHead = True, nodeNext = node1)