Brief Intro
Queue Optimized - dequeue is not O(1)
More Details
if array.count > 50 && percentage > 0.25 {
array.removeFirst(head)
head = 0
}
If the condition happens, the complexity will be O(n/4) ~ O(n)
I think you should use LinkedList to implement a Queue to archive O(1) in all cases of dequeue
Brief Intro
Queue Optimized - dequeue is not O(1)
More Details
If the condition happens, the complexity will be
O(n/4)~O(n)I think you should use
LinkedListto implement aQueueto archiveO(1)in all cases ofdequeue