LinkedList
-
[자료구조] LinkedList개발/자료구조와 알고리즘 2022. 1. 24. 01:07
LinkedList 대표적으로 C같은 경우 선형 자료구조인 Array가 있다. 그러나 이 배열의 경우는 시작부터 크기를 지정해주어야하고, 새로운 요소를 추가하거나, 배열 안의 요소를 제거할 때 비용(시간)이 많이 든다. 이를 개선하기 위해서 구조체를 만드는데, 이 구조체에는 하나의 요소 값과, 다음 구조체의 정보를 가진다. 이 구조체를 연결하여 만드는 리스트가 바로 LinkedList이다. LinkedList를 사용함으로써 크기가 유동적인 자료형을 만들 수 있고, 삽입, 제거에 시간이 적게 든다. 특히 값을 탐색하다가 데이터를 추가, 제거하기에 용이하다. 단점으로는 index가 없어 값을 앞에서부터 탐색해야 한다. -> 탐색에 시간이 많이 소요된다. 종류로는 단순(Single), 양방향(Double)이 ..