The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
15 views
ENQUEUE(Q, x)
1     Q[Q.tail] = x
2     if Q.tail == Q.length
3     Q.tail = 1
4     else Q.tail = Q.tail + 1


DEQUEUE(Q)
1      x = Q[Q.head]
2      if Q.head == Q.length
3      Q.head = 1
4      else Q.head = Q.head + 1
5      return x

illustrate the result of each operation in the sequence ENQUEUE(Q,4),ENQUEUE(Q,1),ENQUEUE(Q,3),DEQUEUE(Q),ENQUEUE(Q,8),DEQUEUE(Q) on an initially empty queue $Q$ stored in array $Q[1...6]$.

in Algorithms by Boss (41.1k points)
edited by | 15 views

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,831 questions
54,735 answers
189,349 comments
80,097 users