A queue is to be held in a linear array called Q with number of elements = limit (numbered 0 to limit-1). The oldest element of the queue is to be held in array element 0 (at the front), the next in array element 1, and so on. A variable back stores the index of the array element containing the newest element in the queue (or -1 for an empty queue).
**
You would simply decrement the index that contains the last element, and return that value. Next time you add something it will overwrite the actual value of the last element. The pseudocode is pretty simple then:
dequeue() {
returnValue = queue[index];
queue.index = queue.index - 1;
return returnValue;
}
IE. Your algorithm is very inefficent. The remove operation can be done in constant time (fast) as opposed to being linear with respect to the number of elements (slower).