Contents

queue

basic operation

op:

  1. enqueue
  2. dequeue
1
2
#define  size  5 
int item[size]

circular queue

![[Pasted image 20221121175921.png]]

op:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
var queueSize = 6
var header,tail  = -1
var circularQ [queueSize]int


isEmpty:
 front= -1

dequeue:
 if isEmpty, return;


 ele =  circularQ[front]

 front = front++ mod  queueSize;

 return ele 

also called: ring buffer

dequeue

the used case