I'm trying to create a circular queue and come across this problem.
As you see, my answer is incorrect. I still don't understand the reason why it is the case, so let's go through everything again.
Following my analysis, the last Front
operation should return 1 as the queue is 1, 1
. However, the answer is 8 instead. Did I miss something? Please explain this for me.
Figured it out. It is required to check whether a queue is full before enqueueing. However, I didn't do so as I thought that circular queue is a form of infinite DS like drop-out stack so my answer is wrong.