What set of conditions is necessary and sufficient for a sequence of insert and remove operations on a single empty queue to leave the queue empty without causing underflow?
What set of conditions is necessary and sufficient for such a sequence to leave a nonempty queue unchanged?
Theoretical question doubt
Hey @Devansh_29
I am not able to understnad your question properly.
From what I can understand.
To avoid underflow
We just check that we are not removing from empty queue
and to keep the queue unchanged , insertion operation should be equal to deletion operations at last such that insertion operation done so far are always >= deletion operations done so far at any point of time