teach-ict.com logo

THE education site for computer science and ICT

3. POP and PUSH data

Since only the items at the head and tail of a queue can be accessed, that makes those the two key parts of the structure. Any new items added to the queue have to appear at one of those two locations.

Adding an item to a queue is called a PUSH command in assembly language. When an item is added, the pointers are updated to connect them to the existing items, like so:

Adding to the head:

Adding to the tail:

 

 

The opposite of a PUSH command is the POP command. This retrieves and removes an item from the queue. Once an item is removed, the pointers in the queue are updated (usually incremented by 1) so they no longer point to it.

The diagram below shows item 'h' being retreived from the front of the queue.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is a queue data structure?