배열

O(1) 인덱스 접근이 가능한 연속 메모리 구조.

배열은 동일한 유형의 요소를 연속된 메모리 위치에 저장하는 기본적인 데이터 구조입니다. 이를 통해 인덱스를 사용하여 상수 시간 O(1)에 모든 요소에 접근할 수 있습니다.

주요 특징:
- 고정 크기
- 빠른 무작위 접근 (Random Access)
- 높은 캐시 효율성

단점으로는 요소를 이동해야 하므로 삽입 및 삭제 비용이 O(n)이라는 점이 있습니다.

        graph LR
  Center["배열"]:::main
  Pre_data_structures["data-structures"]:::pre --> Center
  click Pre_data_structures "/terms/data-structures"
  Rel_linked_list["linked-list"]:::related -.-> Center
  click Rel_linked_list "/terms/linked-list"
  Rel_queue["queue"]:::related -.-> Center
  click Rel_queue "/terms/queue"
  Rel_stack["stack"]:::related -.-> Center
  click Rel_stack "/terms/stack"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 5살도 이해할 수 있게 설명

번호가 매겨진 사물함을 상상해 보세요. 번호를 알면 다른 사물함을 확인하지 않고 바로 갈 수 있습니다. 이것이 배열이 작동하는 방식입니다!

🤓 Expert Deep Dive

공간적 지역성(Spatial Locality)은 CPU 캐시 효율을 극대화합니다. SIMD 명령어는 배열 처리를 가속화합니다. 메모리 정렬(Alignment)은 성능에 중요한 영향을 미칩니다.

🔗 관련 용어

선행 지식:

📚 출처