Oh My Algorithm
Algorithm Guidecomplexity: O(1) enqueue/dequeue

큐 (Queue)

먼저 넣은 것을 먼저 꺼내는 선입선출(FIFO) 구조입니다. 뒤(rear)에서 넣고 앞(front)에서 빼며, BFS·작업 대기열·버퍼링의 기반이 됩니다.

01 Explore How It Works

Interactive Step-by-Step
Queue · FIFO
empty

큐 시작. 뒤(rear)로 넣고 앞(front)으로 빼는 선입선출(FIFO) 구조입니다.

Logic Node1 / 8

02 Understand It Simply

For Everyone
🔑Analogy

매표소 줄. 먼저 줄 선 사람이 먼저 표를 삽니다.

💡In Plain Words

뒤(rear)로 들어가 앞(front)으로 나옵니다.

먼저 넣은 것이 먼저 나와요(선입선출, FIFO).

📍Where It's Used
  • 프린터 인쇄 대기열
  • 고객센터 대기 순번
  • 작업 순서 처리

03 Python Implementation

A clean, readable reference implementation of the core logic of 큐 (Queue).

core_implementation.py
from collections import deque

class Queue:
    def __init__(self):
        self.items = deque()

    def enqueue(self, x):
        self.items.append(x)

    def dequeue(self):
        if not self.items:
            raise IndexError("queue is empty")
        return self.items.popleft()

    def peek(self):
        return self.items[0] if self.items else None

04 Frequently Asked Questions

FAQ
What is 큐 (Queue)?+

먼저 넣은 것을 먼저 꺼내는 선입선출(FIFO) 구조입니다. 뒤(rear)에서 넣고 앞(front)에서 빼며, BFS·작업 대기열·버퍼링의 기반이 됩니다.

What is the time complexity of 큐 (Queue)?+

The time complexity of 큐 (Queue) is O(1) enqueue/dequeue. Follow the step-by-step visualization to see exactly why.

Where is 큐 (Queue) used?+

프린터 인쇄 대기열, 고객센터 대기 순번, 작업 순서 처리.

What's a simple analogy for 큐 (Queue)?+

매표소 줄. 먼저 줄 선 사람이 먼저 표를 삽니다.

Guide Progress0%