Section 7 Chapter 37 - Queues Flashcards
Elementary data type
basic, built in data types such as integer
Composite data types
Built in a data types that area composed of elementary data types, for instance a list
Abstract data type
A data type that is viewed by how the data is viewed and the operations that can be performed on it, without knowing actually how these are done. For instance you may use a queue but not know if it stored as circular or linear queue
Queue
A data structure that functions as a first in first out storage of elements. Elements can (in most cases) only be added to the back of the queue and elements are only taken from the front of the queue.
Example of uses of queues (3)
- Print queue
- Typed characters
- Simulation of a supermarket
Operations on a queue (4)
- Add (enQueue)
- Remove (deQueue)
- Check if empty
- Check if full
Static data structure
A data structure that is fixed in size. It cannot have new memory allocated to it and it cannot free up memory that it isn’t using
Dynamic data structure
A data structure that has the ability to grow or shrink in size. When it requires new memory it can be allocated some heap memory, which can then be de-allocated when it is not needed
Advantages of dynamic data structures (3)
- Can free up unused memory
- Can increase in size if it gets full
- Do not need to specify a size when creating them
Disadvantage of dynamic data structures (1)
Can be more complicated to program one
Advantage of static data structure (1)
In much the same way that a constant is useful, a static data structure can serve as a reminder to a programmer that its size is not meant to change
Disadvantages of static data structures (3)
- Must specify size when created
- Can’t free up memory that it isnt using
- Can’t allocate new memory when it is full
Linear Queue
A list of items that are in the same order of that in which they were added. Has functionality to add an element to the back or to dequeue an element from the front
The two ways to implement a linear queue
- When an item is dequeued, every other item is moved forward one place
- Pointers are created pointing to the front and back of the queue. These are changed as items are added and removed
Circular queue
An implementation of a queue where the elements are stored in a list, with pointers referencing the front and back indexes. When either pointer would be incremented off the end of the list it would instead wrap around through the use of modular arithmetic.