120 likes | 229 Vues
This guide introduces the concept of queues in programming, utilizing arrays for data storage and manipulation. It outlines key functions such as enQueue, deQueue, and the concept of First-In-First-Out (FIFO). Practical examples like operating system task management, online order processing, and printer queues illustrate the use of queues in real-world scenarios. The document explores advanced topics, including the implementation of cyclic queues for efficient space management. Learn how to create, manage, and troubleshoot queues in data structures.
E N D
Queues • Using arrays... • Can populate an array with information... • Then remove it as we deal with it...
Queues • Have 2 functions... • Store data to a queue... • Deal with the data in the queue
Examples • Tasks queued by the OS, (Disk Access) • Orders queued by a shop • Hospital A&E • Printer Queue
Queues • Usually First in First Out(FIFO) • the first item (next to be used) • also called the head or the front • the last item (where we append additions to the queue) • also called the tail or the back
Queue • Once items are in the Queue they cannot be changed
Queue Operations • Create Queue • Delete Queue • enQueue • Serve • getHead • getTail • isFull
Create a Queue • We will need... • An array • Variables for the head + tail • An action to add something to the tail... • An action to serve from the head...
Errors • It should: • Throw an error if we try to add to a full queue • Throw an error if we try to remove from an empty queue
Queues Advanced: Cyclic Queue At the moment we have a limited space... Once the queue is used it is done... This can be sorted by looping back around...
Can we create this... • Need to have a quick algorithm that... • Notices the pointer is at the end of the list • Puts it to the start of the list • Does not over ride any data from the start of the list...