2. Fundamentals of Data Structures Flashcards

1
Q

What is an Array?

A

An Array is an ordered Data Structure which allows multiple values to be stored in a single Variable. Arrays are Static Data Structures, which means they are fixed in size when created. Arrays are highly efficient both in time (O(1)) and space.

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

What is a Record?

A

A Record is a Data Structure which allows a programmer to store related values together as named Attributes.

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

What is the difference between a Text File and a Binary File?

A

A Text File is encoded using either ASCII or Unicode. For example an integer would be encoded as the character values of each digit, rather than the Binary representation of the number itself. A Binary File will use the native Data Type representation to store information in a file. Binary Files are typically smaller than Text Files, but are difficult for a human to read.

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

What is an Abstract Data Type?

A

An Abstract Data Type describes the behaviour of a Data Structure, but not how that behaviour is implemented.

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

What is the difference between a Static and Dynamic Data Structure?

A

A Static Data Structure is fixed in size or capacity when it is created, whereas a Dynamic Data Structure can increase in size to fit whatever Data is inserted.

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

What kind of Data Structure is described as First In First Out (FIFO), and what behaviours does it have?

A

A Queue is First In First Out, the data is removed from a Queue in the same order as it is added.

Data can be Enqueued, inserting at the rear of the Queue.

Data can be Dequeued, removing it from the front of the Queue.

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

Why is a Circular Queue preferable to a Linear Queue?

A

A Linear Queue is slow to Dequeue (O(n)) because all the data items must be shifted forwards. However, a Circular Queue uses two pointers to implement Dequeue faster (O(1)).

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

How do Priority Queues differ from Normal Queues.

A

Each inserted item into a Priority Queue has an associated Priority value. Items with higher Priority will be inserted ahead of items with lower Priority. So a Priority Queue is only First In First Out for items of equal Priority.

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

How is a List different from an Array?

A

An Array is a Static Data Structure, fixed in size when it is created. A List can change in size to fit the contained data. Both are ordered and indexed Data Structures. Depending upon implementation operations on a List may be slower than for an Array.

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

What operations can be applied to a List?

A

Append - add an item to the end of the List.
Prepend - add an item to the front of the List.
Insert - add an item in the middle of the List.
Delete - remove an item from the List.

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

What kind of Data Structure is Last In First Out (LIFO), and what behaviours does it have?

A

A Stack is Last In First Out, data is added to the top of the Stack and also removed from the top. Data will be removed in the reverse order to which it is added.

Data can be Pushed onto the top of the Stack.

Data can be Popped from the top of the Stack.

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

What is a Stack Overflow? What is a Stack Underflow?

A

A Stack Overflow is when there is not enough space left in the Stack to store a new item.

A Stack Underflow is when there is no item to remove from a Stack.

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

What operation are Hash Tables optimised to perform? Why are they good at this?

A

Hash Tables are quick to search (O(1)). This is because they are indexed using a Hash Function, which means you can quickly find where a value should be stored in the underlying Data Structure.

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

What causes Hash Tables to lose performance?

A

Hash Tables lose performance when they are too full. This is because as the Hash Table fills up you get more Collisions between stored values. Collisions mean that a value cannot be stored directly where the Hash Function indicates, and a Linear Search will be required to determine if a value is in the Hash Table.

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

Identify the main differences between a Graph and a Tree.

A

A Tree has a single root node, it is undirected, and has no labels or cycles.

A Graph may be directed, edges may have labels, and it may have cycles.

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

When would you use an Adjacency List as opposed to an Adjacency Matrix to represent a Graph.

A

Adjacency Lists are better at representing Graphs which are sparse - that is they have few edges in relation to the number of possible connections.

17
Q

What properties does a Set have? What operations can be applied to a Set?

A

A Set is an unordered Data Structure which cannot contain duplicates. The following operations can be applied to a Set:

Union - combine two sets into one which contains all the combined values.
Intersection - create a new Set which contains all the values the are in both of the input Sets.
Difference - create a new Set which contains the values which are in one Set but not the other.