{
  "translations" :{
    "en": {
      "sc1": "There remains one more serious, though subtle, problem to the array-based queue implementation. How can we recognize when the queue is empty or full?",
      "sc2": "Assume that front stores the array index for the front element in the queue, and rear stores the array index for the rear element. If both front and rear have the same position, then with this scheme there must be one element in the queue.",
      "sc3": "Thus, an empty queue would be recognized by having rear be <b>one less</b> than front (taking into account the fact that the queue is circular, so position <code>size-1</code> is actually considered to be one less than position 0).",
      "sc4": "But what if the queue is completely full? In other words, what is the situation when a queue with $n$ array positions available contains $n$ elements? In this case, if the front element is in position 0, then the rear element is in position <code>size-1</code>.",
      "sc5": "But this means that the value for rear is one less than the value for front when the circular nature of the queue is taken into account. In other words, the full queue is indistinguishable from the empty queue!",
      "sc6": "You might think that the problem is in the assumption about front and rear being defined to store the array indices of the front and rear elements, respectively, and that some modification in this definition will allow a solution.",
      "sc7": "Unfortunately, the problem cannot be remedied by a simple change to the definition for front and rear, because of the number of conditions or states that the queue can be in.",
      "sc8": "Ignoring the actual position of the first element, and ignoring the actual values of the elements stored in the queue, how many different states are there? There can be no elements in the queue, one element, two, and so on. At most there can be $n$ elements in the queue if there are $n$ array positions. This means that there are $n+1$ different states for the queue (0 through $n$ elements are possible)."
    }
  }
}
