Algorithm/theory
-
[자료구조/알고리즘] 링크드 리스트 자료구조 - ItisFutureAlgorithm/theory 2022. 9. 13. 19:38
링크드 리스트는 노드와 노드를 이어 제한 없이 생성 가능하다는 장점이 있다. 단점은? 즉각적인 인덱싱의 어려움, 메모리를 많이 먹는다. 링크드 리스트의 시작 마지막 노드에 다음 노드를 추가해주는 것을 기억하면 쉽다. ( 기차 놀이 ) class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self, data): self.head = Node(data) def add(self, data): if self.head == '': self.head = Node(data) else: node = self.head while node.next: node = node.next node.ne..