how do i find the number of items in a circular queue?
|front - rear| doesnt always work.
is there one equation to know how many element is in a cir
Assuming you implement it using an array with size N so there are pointers pointing to the front and rear. Use the following formula:
N
size = front > rear ? (front - rear) : (front+N - rear);