Section 7 Chapter 37 - Queues Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Elementary data type

A

basic, built in data types such as integer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Composite data types

A

Built in a data types that area composed of elementary data types, for instance a list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Abstract data type

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Queue

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Example of uses of queues (3)

A
  • Print queue
  • Typed characters
  • Simulation of a supermarket
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Operations on a queue (4)

A
  • Add (enQueue)
  • Remove (deQueue)
  • Check if empty
  • Check if full
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Static data structure

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Dynamic data structure

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Advantages of dynamic data structures (3)

A
  • Can free up unused memory
  • Can increase in size if it gets full
  • Do not need to specify a size when creating them
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Disadvantage of dynamic data structures (1)

A

Can be more complicated to program one

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Advantage of static data structure (1)

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Disadvantages of static data structures (3)

A
  • Must specify size when created
  • Can’t free up memory that it isnt using
  • Can’t allocate new memory when it is full
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Linear Queue

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The two ways to implement a linear queue

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Circular queue

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Disadvantage of a circular queue

A

The maximum size must be known in advance

17
Q

Priority queue

A

A queue where elements are not necessarily added to the back but are instead place in the queue according to their assigned priority. Higher priority elements will be placed towards the front of the queue.

18
Q

How you would add an element to a priority queue

A

Scan the queue from front to back until you find an element with a lower priority than that of the element being added. Insert the element being added in front of the found element