Fundamentals of Data Structures Flashcards

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

What are the built in operations of a stack?

A

Push, Pop, Peek, Is Full, Is Empty

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

What are the built in operations of a queue?

A

Peek, Enqueue, Dequeue, Is Full, Is Empty

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

After extensive data changes a queue will become unusable. Explain why this is so.

A

Memory/queue will become full and space is not reusable.

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

Explain the circumstances in which it would be more appropriate to use an adjacency list instead of an adjacency matrix.

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

What is the definition of a Graph?

A

A collection of nodes and edges.

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

What is the definition of a weighted graph?

A

A graph where each edge has a weight/value associated with it.

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

What is the definition of a tree?

A

A graph that: is undirected, has no cycles/loops and is connected,

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

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.

A
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)

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

What is the vector dot product of u and v?

A

(U.V) / (|U|.|V|) where |Vector| = Root [(X2 - X1)^2 + (Y2 - Y1)^2]

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