Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //DEFINIZIONI CODA
- CREATE-QUEUE(maxSize)
- //C è una nuova coda di dimensione maxsize
- c.head = -1
- c.tail = -1
- return c;
- IS-EMPTY(c)
- if(c.head == c.tail)
- return TRUE
- return FALSE
- ENQUEUE(c, x)
- if(c.head+1==c.tail || c.tail=0 && c.head==c.lenght-1)
- return overflow
- c[c.tail] = x
- if(c.tail==c.lenght-1)
- c.tail=0;
- else
- c.tail=c.tail+1
- DEQUEUE(c)
- if(c.head == c.tail)
- return underflow
- temp = c[c.head]
- if(c.head ==0)
- c.head = c.lenght-1
- else
- c.head = c.head+1
- return temp
- FRONT(C)
- if(l.head==c.head)
- return error underflow
- return c[c.head]
- EMPTY(l)
- l.head==-1
- l.head==l.tail
- return l;
- SIZE(c)
- if(c.tail==c.lenght-1)
- return (c.lenght-1) - c.head
- if(c.tail>c.head)
- return c.tail-c.head
- return (c.lenght-1 - c.head)+c.tail
- Tempo di esecuzione per ogni operazione: Teta(1)
Add Comment
Please, Sign In to add comment