로그인 바로가기 하위 메뉴 바로가기 본문 바로가기

데이터 구조 및 분석: Linear Structure and Dynamic Programming

임시 이미지 KAIST 산업및시스템공학과 문일철
http://kooc.kaist.ac.kr/datastructure-2019s/forum/12988
좋아요 1779 수강생 3367
def removeFirst(self):
# Problem 1. complete the remove first function of a doubly linked list
# remove the node at the first of the linked list
node = self.nodeHead.getNextNode()
if node.strSerialNumber != 'tail':
nextNode = node.getNextNode()
nextNode.setPrevNode(self.nodeHead)
self.nodeHead.setNextNode(nextNode) // 동영상에는 괄호안에 node로 되어있습니다
return node


def getSize(self):
# Problem 1. complete the code of a doubly linked list to
# return the size of the linked list excluding head and tail nodes
node = self.nodeHead
cnt = 0
while node.getNextNode().strSerialNumber != 'tail':
node = node.getNextNode() // 여기또한 동영상에는node.nextNode()로 되어있습니다
cnt = cnt+1
return cnt
하지만 Plannode의 클래스 안에 nextNode는 맴버함수가 아닌 맴버변수아닌가요? getNextNode가되
어야 되는게 아닌가요??
영상그대로 코드를 입력시 그래프 실행이 안되는 문제가 발생합니다.
제가 잘못쳤을 가능성도 있지만 아무리봐도 없는것 같아서 여쭈어봅니다
답코드를 올려주시거나 영상을 수정해 주시면 감사할것 같습니다~
def get(self):
# Problem 2. complete the remove function of Stack
# remember Stack has LIFO characteristics
node = self.List.nodeHead.getNextNode()
return node
여기 stack 함수의 get 함수에도 영상에서는 getFirst라는 없는함수를 쓰셨는데 어디에 있는
함수인가요??