Implementing a Queue - Resizing Array
Similar in concept to the resizing array in a stack to simplify the process we would essentially break down the process with the bellow pseudo code.
- use an array to store our items lets say
q[]
- our
enqueue()
function would add new items atq[tail]
- our
dequeue()
function would remove items fromq[head]
- We would update our
head
andtail
according to a modulo of ourcapacity
- that would in turn be amortizing and adding the resizing array to our client.