Fundamentals of Data Structures Flashcards
What are the built in operations of a stack?
Push, Pop, Peek, Is Full, Is Empty
What are the built in operations of a queue?
Peek, Enqueue, Dequeue, Is Full, Is Empty
After extensive data changes a queue will become unusable. Explain why this is so.
Memory/queue will become full and space is not reusable.
Explain the circumstances in which it would be more appropriate to use an adjacency list instead of an adjacency matrix.
- When the graph/matrix is sparse.
- When the edges are rarely changed.
- When the presence/absence of specific edges does not need to be tested (frequently).
What is the definition of a Graph?
A collection of nodes and edges.
What is the definition of a weighted graph?
A graph where each edge has a weight/value associated with it.
What is the definition of a tree?
A graph that: is undirected, has no cycles/loops and is connected,
A binary tree could be represented using one array of records or, alternatively, using three one-dimensional arrays.
Describe how the data stored in the array(s) could be structured for each of these two possible methods of representation.
For solution with 3 arrays: One array stores data items One array for left child pointers One array for right child pointers Pointers stored at same location in arrays as corresponding data item
For solution with 1 array of records:
Record created to store data item and pointers
One pointer to left child
One pointer to right child
For either of the above solutions:
Rogue value used to indicate no child
Root node stored at first location/start of array(s)
What is the vector dot product of u and v?
(U.V) / (|U|.|V|) where |Vector| = Root [(X2 - X1)^2 + (Y2 - Y1)^2]