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

데이터 구조 및 분석: Non-Linear Structure, Optimization, and Algorithms

임시 이미지 KAIST 산업및시스템공학과 문일철 교수
http://kooc.kaist.ac.kr/datastructure-2019s2/forum/10706
좋아요 554 수강생 1709
def enqueueWithPriority(self, value, priority):
idxInsert = 0
for itr in range(self.list.getSize()):
node = self.list.get(itr)
if node.getValue() == '':
idxInsert = itr
break
if node.getValue().getPriority() < priority:
idxInsert = itr
break
else:
idxInsert = itr + 1
self.list.insertAt( PriorityNode(value, priority), idxInsert )

list 사이즈 만큼 돌기 때문에 value가 비어있는 경우는 없을 거 같은데 if node.getValue()=='' 부분이 참이 되는 경우가 있는지 궁금합니다.