Array Implementation of Queue (Fixed size)


reuse a fixed size array. —-> Tracking 2 variables frontIndex for deletion and rearIndex for insertion.


  1. array size > 0.
  2. isEmpty()
  3. Check rearIndex == frontIndex.
  4. Enqueue –> queue is full.
  5. Dequeue –> queue is empty.

Complexity Analysis:

Time complexity :
enqueue: O(1)
assign the value to array[rearIndex]

dequeue: O(1)
move frontIndex to next index.

Space complexity : O(n)


The result:

Screen Shot 2017-04-12 at 9.48.43 PM

Exception checking:

Screen Shot 2017-04-12 at 9.56.48 PMScreen Shot 2017-04-12 at 9.57.41 PMScreen Shot 2017-04-12 at 9.58.28 PM


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s