def _exchange(self, i, j):
if self.x[i] < self.x[j]:
self.x[i], self.x[j] = self.x[j], self.x[i]
def push(self, item):
self.x.append(item)
cIndex = len(self.x) - 1
pIndex = cIndex // 2
while pIndex >= 1:
self._exchange(pIndex, cIndex)
cIndex = pIndex
pIndex = cIndex // 2
'자료구조' 카테고리의 다른 글
BFS (0) | 2024.12.06 |
---|---|
이진 탐색 트리 (0) | 2024.12.06 |
탐욕 알고리즘, 최소 비용 신장 트리 (0) | 2024.12.05 |
BFS 알고리즘, 다익스트라 알고리즘 (0) | 2024.12.02 |
해시 테이블 (0) | 2024.12.02 |