Programming a Queue

As a programmer, you only have to worry about the top element in the queue and the last element. This is because you will enqueue, or add items to the end of the queue, and dequeue, or remove the first, or top, element of the queue. When you add an item to the queue, you…

How Queues Work

A queue is a fairly common data storage method. However, unlike many methods of storing data, where we keep the data for the entire runtime of a function or even the entire application, a queue’s data is designed to be consumable. That is, at some point data will enter the queue, and then it will…

Stacks in Computers

Stacks don’t have as much use in computers as a queue, however, when you need to use one, they are very beneficial. Two of the most common uses of stacks are to help with Expression Conversion (Infix to Postfix, Postfix to Prefix, etc.) and especially with the parsing of data.  When parsing source files before…

Page Replacement with Fixed # of Frames

A reference string is the sequence of page numbers referenced by an executing program during a given time interval. Reference strings are used to compare different page replacement algorithms by counting the number of page faults generated. Since page faults are time consuming, the optimal page replacement algorithm selects the page that will not be referenced for the longest…