Unit 7 - Data Structures Flashcards
define array
a finite, ordered set of elements of the same type.
what is a 2-dimensional array
a collection of data elements arranged in a grid-like structure with rows and columns
define tuple
an ordered set of values, which could be elements of any type (images, sound files, strings,etc) that is immutable, which means that elements cannot be changed, and you cannot dynamically add elements or delete elements form a tuple.
what’s the difference between static and dynamic data types
dynamic data types - change size when required (lists grow when items are added and shrink when items are removed). it does this with the aid of heap (specific area of memory)
static data types - cannot change size (array)
what is an abstract data type
one that is created by a programmer
- a logical description of how the data is viewed and the operations that can be performed on it
what is an elementary data type
defined within the programming language
what are the four operations with a queue
- enQueue(item)
- deQueue
- isEmpty
- isFull
what is a queue
a queue is a first in first out data structure. new elements can only be added to the end of the queue, and elements may only be retrieved from the front of the queue
applications of queues
- printing from computers (print queue)
- typing on a keyboard
- simulations
what does enQueue(item) do
add a new item to the rear of the queue
what does deQueue() do
remove the front item from the queue
what does isEmpty() for queues do
test to see whether the queue is empty
what does isFull() for queues do
test to see whether queue is full
what is a circular queue
one way of overcoming the limitation of a static data structure by reusing the spaces that have been freed by dequeuing from the front of the array. If you see a MOD and a length function when looking at lists you will know that it is a circular queue.
pseudocode to initialise a circular queue
pseudocode to test for an empty queue
pseudocode to test for a full queue
pseudocode to add an element to the queue
pseudocode to remove an item from the queue
what is a priority queue
it acts like a queue in that items are dequeue by removing them from the font of the queue. however, the logical order of items within the queue is determined by their priority, with the highest priority items at the front of the queue and the lowest priority items at the back.
what is a list
an abstract data type consisting of a number of items in which the same item may occur more than once
what are the main operations on lists
- isEmpty()
- append(item)
- remove(item)
- search(item)
- length()
- index(item)
- insert(pos, item)
- pop()
- pop(pos)
what does isEmpty() on lists do
test for empty list
what does append(item) do
add a new item to list to the end of the list