Data structure, the problem of queue head pointer front, queue tail pointer rear

there is a little doubt about the queue in the soft exam "Software designer tutorial".

my understanding of the queue:

  1. when the queue is empty, front=rear=null, has no problem pointing two pointers to the bottom line.
  2. after joining the queue for 1 element, the front remains unchanged, but it is still null,rear+1, that should point to the storage unit "0" at this time.
  3. in figure b, if there are three elements in the queue, the rear should point to the storage unit "2", but figure B points to "3".

what"s going on at this time?

  1. in addition, shouldn"t the header and tail pointers of the queue point to the storage unit? The pointers on the picture are all on the separation line. What does this separation line mean?
Aug.27,2021

    As long as you can understand the meaning of
  1. , don't delve into the picture. I guess what the figure means is that both pointers store array subscripts and point to the split line to represent-1, so when the three elements in figure b join the queue, Q.front is drawn on the partition line, indicating that the queue header is still in the original position, while Q.rear points directly to the next empty unit. Finally, when the team is full, Q.rear also points to the split line, indicating that there is no new remaining space in the queue, so it is also-1.
  2. from 1, I think it depends on how you define the two pointers. If the first pointer points to the first element and the end pointer points to the tail element, then after a data element joins the queue, they should all point to the storage unit with the subscript 0; and if you want the team leader to point to the null to represent the original state, and the end of the queue to the tail element, you should run according to your algorithm. This depends on your actual definition, it doesn't matter if the algorithm is different, as long as you can run and pass the test without bug.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3507f-2b6db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3507f-2b6db.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?