This post was written based on what I've learn in college class and the materials I looked for. Also, it was written to study while reviewing, so there may be insufficient or wrong information. If there's anything to fix, please leave a comment!
A queue is an example of a linear data structure, or more abstractly a sequential collection. Queues are common in computer programs, where they are implemented as data structures coupled with access routines, as an abstract data structure or in object-oriented languages as classes.
A line or sequence of people or vehicles awaiting their turn to be attended to or to proceed.
A collection of entities that are maintained in a sequence and can be modified by the addition of entities at one end of the sequence and the removal of entities from the other end of the sequence.
A structure in which elements are added to the rear and removed from the front; a "First in, First out" (FIFO) structure.
One of the real-life example of queue is that getting in the line to order in McDonald's. The person who comes earlier through the door orders first and leave the line. The other people who come next order next and leave the line. In this situation, the door of this store is the entry(rear) of the queue, the line is the queue, and the other end that people leave after order is the exit(front) of the queue.
Simply we usually call it "First come, First serve".
In a stack we remove the element the most recently added. In a queue, we remove the element the least recently added.
Constructor
Transformers
Observers
They have no effect on the queue.
enqueue, dequeue, front, and rear are O(1).
Array-based, Linked-based.
All operations are O(1), except for the constructors
https://github.com/namdarine/DataStructure.git
QueueInterface, QueueOverflowException, QueueUnderflowException, Fixed Front Queue, Floating Front Queue, Wrap around with floating front Queue, and Linked list Queue codes are uploaded in this github repository.
λ³Έ ν¬μ€ν μ νκ΅μμ λ°°μ΄ μμ λ΄μ©κ³Ό λ μ°Ύμλ³Έ μλ£λ₯Ό κΈ°λ°μΌλ‘ μμ±νμμ΅λλ€.
λ€μ 볡μ΅νλ©΄μ 곡λΆνκΈ°μν΄μ μμ±νμμΌλ―λ‘ λΆμ‘±νκ±°λ μλͺ»λ κ²μ΄ μμ μ μμ΅λλ€.
μμ μ¬νμ΄ μλ€λ©΄ λκΈ λ¬μμ£ΌμΈμ!
νλ μ ν λ°μ΄ν° ꡬ쑰μ μμ΄κ³ , λ μΆμμ μΌλ‘ μμ°¨μ 컬λ μ μ΄λ€. νλ μ κ·Ό 루ν΄κ³Ό κ²°ν©λ λ°μ΄ν° ꡬ쑰, μΆμ λ°μ΄ν° ꡬ쑰 λλ ν΄λμ€λ‘ κ°μ²΄ μ§ν₯ μΈμ΄λ‘ ꡬνλλ μ»΄ν¨ν° νλ‘κ·Έλ¨μμ νν λ³Ό μ μλ€.
μ°¨λ‘λ₯Ό κΈ°λ€λ¦¬κ±°λ μ§ννκΈ° μν΄ λκΈ° μ€μΈ μ¬λμ΄λ μ°¨λμ μ€ λλ μμ.
μνμ€μμ μ μ§λκ³ μνμ€μ ν λμ μμλ₯Ό μΆκ°νκ³ λ€λ₯Έ λμλ μμλ₯Ό μ κ±°νμ¬ μμ ν μ μλ μμλ€μ μ§ν©μ΄λ€.
μμκ° λ€μ μΆκ°λκ³ μμμ μ κ±°λλ κ΅¬μ‘°λ‘ "μ μ
μ μΆ" ꡬ쑰μ΄λ€.
μ°λ¦¬ μΌμμνμμ νν λ³Ό μ μλ νμ μμλ‘λ 물건μ ꡬμ
νκΈ° μν΄ μμλ μ€μ΄λ€. λ¬Έμ ν΅ν΄μ μ¬λλ€μ΄ 맀μ₯μΌλ‘ λ€μ΄μ€κ³ μ£Όλ¬ΈνκΈ° μν΄μ μ€μ μ λ€. λ¨Όμ λ€μ΄μ¨ μλμ λ€λ₯Έ λ€μ μλ μ¬λλ³΄λ€ λ¨Όμ μ£Όλ¬Ένκ³ μ€μμ λκ°λ€. κ·Έ λ€μ μλλ λ§μ°¬κ°μ§λ‘ μ£Όλ¬Έμ νκ³ μ€μμ λκ°λ€. μμ°¨μ μΌλ‘ μ£Όλ¬Έμ νκ³ μ€μμ λκ°λ€. μ¬κΈ°μ 'λ¬Έ'μ νμ μ
ꡬ, μ¦ λ€μͺ½μ΄λ€. 'μ€'μ ν 본체μ΄κ³ , μ£Όλ¬Ένλ μͺ½μ νμ μΆκ΅¬, μ¦ νμ μμͺ½μ΄λ€.
μ€νμ κ°μ₯ μ΅κ·Όμ μΆκ°λ μμλ₯Ό μ κ±°νλ€. λ°λλ‘ νλ κ°μ₯ λ¨Όμ μΆκ°λ μμλ₯Ό μ κ±°νλ€.
μμ±μ
νΈλμ€ν¬λ¨Έ
κ΄μ°°μ
νμ λΌμΉλ μν₯μ μλ€.
enqueue, dequeue, front κ·Έλ¦¬κ³ rear μ°μ°μ O(1)μ΄λ€.
Array-based, Linked-based
μμ±μλ₯Ό μ μΈν λͺ¨λ μ°μ°μ O(1)μ΄λ€
https://github.com/namdarine/DataStructure.git
μ΄ κΉνλΈ λ νΌμ§ν 리μ QueueInterface, QueueOverflowException, QueueUnderflowException, Fixed Front Queue, Floating Front Queue, Wrap arround with floating front Queue, and Linked list Queue μ½λλ€μ΄ μμ΅λλ€.