Stacks & Queues in Computer Studies 📚

Learn about stacks and queues, their order of data arrival, and how they manage information in computer systems.

Stacks & Queues in Computer Studies 📚
Notes Reel
107 views • Oct 17, 2022
Stacks & Queues in Computer Studies 📚

About this video

Information arrives at a computer in a particular order, it may not be numeric, or alphabetic, but there is an order dependent on the time that it arrives. Imagine Zaid, Iram, Sahin, Rashid send jobs for printing, in that order. When these jobs arrive, they are put in a queue awaiting their turn to be dealt with. It is only fair that when a job is called for by the printer that Zaid's job is sent first because his has been waiting longest. These jobs are held, just like the other data we have been talking about, in an array. The jobs are put in at one end and taken out of the other. All the computer needs are a pointer showing it which one is next to be done (start pointer (SP)) and another pointer showing where the next job to come along will be put (end pointer (EP)).

1. Zaid is in the queue for printing, the end pointer is pointing at where the next job will go.

2. Iram's job is input and goes as the next in the queue, the end pointer moves to the next available space.

3. Zaid's job goes for printing so the start pointer moves to the next job, also Sahin's job has been input so the end pointer has to move.

Notes: The array is limited in size, and the effect of this seems to be that the contents of the array are gradually moving up. Sooner or later the queue will reach the end of the array. The queue does not have to be held in an array; it could be stored in a linked list. This would solve the problem of running out of space for the queue, but does not feature in this course until the second year. The example of jobs being sent to a printer is not really a proper queue, it is called a spool, but we don't need to know about the difference until chapter 3.1

Stacks

Imagine a queue where the data was taken off the array at the same end that it was put on. This would be a grossly unfair queue because the first one there would be the last one dealt with. This type of unfair queue is called a stack. A stack will only need one pointer because adding things to it and taking things off it are only done at one end.

1. Zaid and Iram are in the stack. Notice that the pointer is pointing to the next space.

2. A job has been taken off the stack. It is found by the computer at the space under the pointer (Iram's job), and the pointer moves down one.

3. Sahin's job has been placed on the stack in the position signified by the pointer, the pointer then moves up one. This seems to be wrong, but there are reasons for this being appropriate in some circumstances which we will see later in the course.

In a queue, the Last one to come in is the Last one to come Out. This gives the acronym LILO, or FIFO (First in is the first out). In a stack, the Last one in is the First one Out. This gives the acronym LIFO, or FILO (First in is the last out).
#componentsofacomputer #computersystem #modesofuse
#computerstudies9608 #alevelnotes #notesreels #Chapter1.4 #systemsoftware #operatingsystem #data #DataItsRepresentation
#StructureandManagement #stacks #queues @Notesreel

Tags and Topics

Browse our collection to discover more content in these categories.

Video Information

Views

107

Duration

3:09

Published

Oct 17, 2022

Related Trending Topics

LIVE TRENDS

Related trending topics. Click any trend to explore more videos.