Suppose we have an initially empty queue Q as well as a set…
Suppose we have an initially empty queue Q as well as a set of items that Q may contain. Also suppose we have operations ENQUEUE(Q,x), which adds item x to the back of queue Q, DEQUEUE(Q), which removes an item from the front of queue Q, and MULTI-DEQUEUE(Q,k), which removes first k elements from the from the front of queue Q. Assume the true cost for both ENQUEUE and DEQUEUE is each 1, respectively. Now suppose we are trying to amortize the cost of these operations using the potential method, and suppose the operation on Q is MULTI-DEQUEUE(Q,k). We have a potential function
Read Details