Working Ordered linked list:
• Eachinteger in the queue is stored inside of a QueueItem. The QueueItem contains the integer, and a pointer to the next item in the queue.
For example, the QueueItem below stores aninteger16 and the next pointer has been set to NULL.
![1876_Working of Ordered linked list.png](https://www.expertsmind.com/CMSImages/1876_Working%20of%20Ordered%20linked%20list.png)
• The Queue class has two member variables, head and tail, which point to the first and the last item in the queue, respectively. Both of these start off as NULL pointers.
![916_Working of Ordered linked list1.png](https://www.expertsmind.com/CMSImages/916_Working%20of%20Ordered%20linked%20list1.png)
• When push is called, a new QueueItem is created with that integer stored. This is placed at the back of the queue
For example, if we inserted 7 in the empty queue above, the head and tail pointers would simply be set to point to this new item.
![59_Working of Ordered linked list2.png](https://www.expertsmind.com/CMSImages/59_Working%20of%20Ordered%20linked%20list2.png)
• Now, say we pushed10 onto the queue. We want this to be inserted at the end of the queue as shown below, with the tail pointer pointing to the newly inserted item
![628_Working of Ordered linked list3.png](https://www.expertsmind.com/CMSImages/628_Working%20of%20Ordered%20linked%20list3.png)
• Now push45 and 16 onto the queue
![1510_Working of Ordered linked list4.png](https://www.expertsmind.com/CMSImages/1510_Working%20of%20Ordered%20linked%20list4.png)
• Removal is done from the front of the queue, if we called pop the result would be
![1322_Working of Ordered linked list5.png](https://www.expertsmind.com/CMSImages/1322_Working%20of%20Ordered%20linked%20list5.png)