algoritmauzmanı
Sign in
TREN
Subtopic 5.1

Queue with an Array

5lessons24 min0done

A queue built on an array keeps its elements in a fixed-size array. The index knows where the first element is and the index knows where the last one is. In an empty queue front is 0 and rear is -1.

Each operation is its own lesson: creating, , and . The last lesson shows the weak spot of this simple version: cells freed at the front by dequeue can never be used again.

Lesson 5.1.1 Creating an array queue5 min