当前位置:网站首页>Stack and queue-p79-9

Stack and queue-p79-9

2022-07-07 06:34:00 DanStevensBigFan

The maximum capacity of the queue is MaxSize

This sentence does not mean that the number of elements when the queue is full is MaxSize

 

  In this case, the maximum capacity is MaxSize

No other data members have been requested

The condition for judging the queue is Q.front == (Q.rear+1)%MaxSize

        explain

                Popular explanation ,(Q.rear+1)%MaxSize Represents in the loop queue (rear Value +1)

                From the image, it is the current rear The next object of the object pointed to

                %MaxSize Important properties of loops

                Try a few more pictures , And substitute numbers

              

This method has additional data members size As the companion variable of the queue

  This method has additional data members tag As companion variables for insert and delete operations

So from the three figures, it can be concluded that no other data members that meet the meaning of the question are Figure 1 , Waste a piece of memory

That is to say Q.front == (Q.rear+1)%MaxSize

原网站

版权声明
本文为[DanStevensBigFan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130718189872.html