기타/What I Learned
[자료구조&알고리즘] 연결 리스트(1)
가죽방패
2021. 9. 26. 22:30
※ 연결 리스트 (Linked Lists)
- 추상적 자료구조 (Abstract Data Structures)
# 특정 원소 참조
def getAt(self, pos):
if pos <= 0 or pos > self.nodeCount:
return None
i = 1
curr = self.head
while i < pos:
curr = curr.next
i += 1
return curr
배열 | 연결 리스트 | |
저장 공간 | 연속한 위치 | 임의의 위치 |
특정 원소 지칭 | 매우 간편 | 선형탐색과 유사 |
O(1) | O(n) |