马一下循环队列的公式

链接:https://www.nowcoder.com/questionTerminal/baa8634c3bde4f5bac0085265c83fa9d?toCommentId=1337461
来源:牛客网

循环队列的相关条件和公式:
1.队空条件:rear==front
2.队满条件:(rear+1) %QueueSIze==front,其中QueueSize为循环队列的最大长度
3.计算队列长度:(rear-front+QueueSize)%QueueSize
4.入队:(rear+1)%QueueSize
5.出队:(front+1)%QueueSize
这里出队(front+1)%QueueSize,QueueSize是数组大小,也就是m+1。

猜你喜欢

转载自www.cnblogs.com/claudia529/p/11072230.html