Professional Documents
Culture Documents
To push an item :
To pop an item :
As an array, stacks have a finite size and can be full (this condition must be allowed)
---------------------------------------------------------------------------------------------------------------------
----------
Follows the First In, First Out (FIFO) principle – the first item to be added is the first to be
removed
Items can be added to the queue (enqueue)
Items can be removed from the queue (dequeue)
Examples :
Management of files sent to a printer
Buffers used with keyboards
Scheduling
A queue uses two pointers :
A front pointer – that points to the first item in the queue
A rear pointer – that points to the last item in the queue
Queue operations :
Value of frontPointer changes after dequeue
Value of rearPointer changes after enqueue
As an array, queues have a finite size and can be full (this condition must be allowed)
The items are removed from the front and added to the back
QUEUE IS MANAGED AS A CIRCULAR QUEUE
Both pointers, frontPointer and rearPointer are at the first element in the array (lower
bound)
To set up a queue :
To add item onto queue :
To remove item from queue :
---------------------------------------------------------------------------------------------------------------------
----------
A list containing several items in which each item in the list points to the next item in the
list
A new item is always added to the start of the list
A linked list uses a start pointer that points to the first item in the linked list
Every item is stored together with a pointer to the next item. This is called a node
The last item in the linked list has a null pointer
What is called a node?
Explain linked list