Stack과 Queue

Computer Science/Data Structure

Stack

마지막에 넣은 게 먼저 나오는 LIFO(Last In First Out) 구조의 자료구조이다. LIFO가 전부 Stack은 아니고 삽입, 삭제, 조회는 무조건 Top에서만 이루어지고 중간 삭제/임의 접근 없음 제약을 지킬 때 Stack이라고 부른다.

 

배열 혹은 연결 리스트로 구현한다. top을 배열의 끝 혹은 연결리스트의 머리에 두고 push/pop 연산을 실행한다.

연결리스트로 구현한 경우 노드 오버헤드/포인터 추적으로 인한 오버헤드가 생겨 일반적으로 배열을 기반으로 구현한다.

Stack

 

Queue

먼저 넣은 게 먼저 나오는 FIFO(First In First Out) 구조의 자료구조이다. Stack과 마찬가지고 FIFO면 모두 Queue가 아니라 삽입은 rear에, 삭제/조회는 front에서 이루어지고 우선순위/중간 삭제 없음 제약을 지킬 때 Queue라고 부른다.

 

Stack과 마찬가지로 배열 혹은 연결 리스트로 구현한다. Stack처럼 대부분은 배열로 구현된다. 하지만 일반적인 배열이 아닌 원형 배열을 기반으로 head/tail 인덱스만 이동하는 식으로 구현된다.

Queue

 

변형

Deque

양 쪽에서 삽입/삭제 연산이 가능한 Queue의 변형이다.

Deque

 

PriorityQueue

이름에 Queue가 들어갔지만 사실은 먼저 들어오는 데이터가 아닌 우선순위가 높은 데이터가 먼저 나가는 형태의 자료구조이다. 이전에 작성했던 Heap으로 구현된다.

 

참고

https://www.geeksforgeeks.org/dsa/stack-data-structure/

 

Stack Data Structure - GeeksforGeeks

Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.

www.geeksforgeeks.org

 

https://www.geeksforgeeks.org/dsa/queue-data-structure/

 

Queue Data Structure - GeeksforGeeks

Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.

www.geeksforgeeks.org

https://www.geeksforgeeks.org/dsa/deque-set-1-introduction-applications/

 

Deque Data Structure - GeeksforGeeks

Your All-in-One Learning Portal: GeeksforGeeks is a comprehensive educational platform that empowers learners across domains-spanning computer science and programming, school education, upskilling, commerce, software tools, competitive exams, and more.

www.geeksforgeeks.org

 

'Computer Science > Data Structure' 카테고리의 다른 글

Hash Table  (0) 2025.09.19
Heap  (0) 2025.09.06
Array와 LinkedList  (0) 2025.08.21
'Computer Science/Data Structure' 카테고리의 다른 글
  • Hash Table
  • Heap
  • Array와 LinkedList
hojoo
hojoo
그냥 개발이 즐거운 사람
  • hojoo
    dev_record
    hojoo
  • 전체
    오늘
    어제
    • 분류 전체보기 (84)
      • Study (0)
        • 모든 개발자를 위한 HTTP 웹 기본 지식 (0)
        • Real MySQL 8.0 (0)
        • 친절한 SQL 튜닝 (0)
        • 도메인 주도 개발 시작하기 (0)
        • 대규모 시스템 설계 기초 (0)
      • Computer Science (68)
        • Problem Solving (30)
        • Data Structure (4)
        • Spring Boot (14)
        • DB (1)
        • Java (4)
        • OS (3)
        • Server (3)
        • Tech (0)
      • Security (16)
        • Reversing (15)
        • Assembly (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    서버 증설 횟수
    자료구조
    n+1
    servlet
    Reversing
    21278
    2539
    13265
    19622
    n^2 배열 자르기
    x64dbg
    레나 튜토리얼
    Spring boot
    9421
    리버싱 핵심원리
    DP
    DB
    PE header
    Lena tutorial
    소수상근수
    12033
    리버싱
    16946
    Header
    프로그래머스
    15973
    bean
    HTTP
    dreamhack.io
    백준
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
hojoo
Stack과 Queue
상단으로

티스토리툴바