Programming: Data Structures Flashcards
List some data types
•integer
•string
•float
•boolean
•character
•nothing
What is a data type?
They represent the category of data being stored, not the data itself
List some data structures
Built in:
•List
•Array
•Dictionary
•Tuple
•Set
User defined:
•Stack
•Queue
•Tree
•Graph
•Hash map
Define Static data types
The size of the data structure cannot be changed during run time. The content can be modified but the memory allocated to it stays the same
Is an array:
a) [1,2,3]
b) {1,2,3}
c) {1:’c’, 2:’a’,3:’t’}
b
Describe the meaning of “data structure”
A container within which information is stored
Give three properties of an array
-finite
-indexed
-only containing elements of the same data type
-mutable
Give examples of data types
-interger
-float
-string
-boolean
-null
Give examples of user defined data structures
-stack
-queue
-tree
-linked list
-graph
-hash map
Give examples of built in data structures
-list
-array
-dictionary
-tuple
-set
Describe a static data structure
Size of the data structure is fixed and cannot be changed in runtime. The data contained in the structure may be modified but the memory allocated to it does not.
Describe a dynamic data structure
The size of the data structure can be changed in run time. The data stored in the data structure as well as its memory space allowed can be modified
Difference between dynamic and static data structures:
-dynamic: memory is allocated dynamically/as the program executes
Static: memory is allocated at comple time. Fixed size
Advantage of static data structures:
-easier to add and remove elements, with fast access times
-locations of items within the structure do not need to be kept track of, simple indexing
Disadvantage of static data structures:
-if a large amount of memory is allocated to the structure, space could easily be wasted.
-stack overflow errors possible
Advantage of dynamic data structures:
-uses memory efficiently as the structure only takes up as much space as it needs
Disadvantage of dynamic data structures:
-harder to program with, as the size of the structure and the locations of items within it need to be monitered
Describe an abstract data structure:
Don’t exist as data structures in their own right, but use other data structures (like arrays) to form a new way of storing data
Give an example of an abstract data structure:
-queues
-stacks
-graphs
What data structure is a queue based on?
An array.
What type of abstract data structure is a queue?
FIFO structure
Where are queues used in a computer system?
-used in keyboard buffers. Each key pressed is added to the queue and removed once it has been processed/displayed- meaning letters appear in the same order they were pressed
Give other examples of queues in action:
-keyboard buffer
-printer management
-task scheduling
-breadth-first search algorithms
What is a BFS
breadth first search algorithm
What is a breadth first search algorithm?
Used in searching tree data structures for a specific node. Begins at the root and searches each node on a current depth before moving on to the nodes at the next depth level.