Data Structures Flashcards

1
Q

What is a compound or complex data type?

A

When existing data types are combined to create a new data type

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

What is a data structure?

A

An organised collection of data that can be processed more easily

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

What is a static data structure?

A

A certain amount of memory is reserved for the data structure when it is created

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

What is a dynamic data structure?

A

Memory efficient data structure as memory is used when needed and only limited to the memory allocation of the program (the heap)

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

What type of data structure is a stack?

A

A First In Last Out (FILO) data structure

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

What is used to reference the value at the top of the stack?

A

A pointer variable holding the index of the value

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

What type of data structure is a queue?

A

A First In First Out (FIFO) data structure

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

How are pointers used in a queue?

A

There are front and rear pointers that hold the indexes of the front and rear values

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

What is a priority queue?

A

Adds values at different priority levels in a queue instead of in the order they are added

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

What is the heap?

A

A large chunk of unallocated RAM that can be used by dynamic data structures

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

What is the purpose of a circular queue?

A

Solves the problem that occurs when the end of a queue is reached and there empty spaces but data can’t be added

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

How does a dictionary store data?

A

As key-value pairs

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

What is the main advantage of using keys in data structures such as dictionaries?

A

They allow direct access which is quicker to access than unordered data

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

How are dictionaries often implemented using?

A

Hash tables

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

What are buckets in a hash table?

A

A position in the hash table array

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

What is the load factor in a hash table?

A

The proportion of buckets occupied, the optimal is 0.75

17
Q

How is the load factor of a hash table calculated?

A

Number of occupied buckets / total number of buckets

18
Q

What is a hash function?

A

An algorithm that converts a hash key to a hash value

19
Q

What are the two main methods of avoiding collisions in a hash table?

A

Linear probing and chaining

20
Q

When is rehashing needed in a hash table?

A

When performance degrades due to many values being added or deleted

21
Q

What are rainbow tables?

A

Tables that store pre-hashed values of possible passwords

22
Q

What is a random salt?

A

A random piece of data added to a password before they are hashed that is stored with the user id

23
Q

What does a graph represent?

A

Complex, non-linear relationships (edges) between objects (nodes)

24
Q

What are directed graphs?

A

Graphs with edges represented with arrows to show which direction the nodes can be visited

25
Q

What are weighted graphs?

A

Where values are associated with edges

26
Q

What is an adjacency matrix (when used to implement a graph)?

A

A 2D array that has values for whether there is an edge and a weight, it is symetrical if the graph is undirected

27
Q

What is an adjacency list (when used to implement a graph)?

A

A list of all neighbours for each node which can include other values such as weight

28
Q

What is a tree?

A

A connected, undirected graph with no cycles

29
Q

What is a rooted tree?

A

A tree with a specific starting node that is normally represented above all other nodes

30
Q

What is a binary tree?

A

A rooted tree where every node can only have up to two child nodes

31
Q

What is a binary search tree?

A

A tree used to optimise searching by placing values lower than the root the left and the higher values to the right

32
Q

What are the three main tree traversals?

A

Pre-order (root, left, right), in-order (left, root, right), post-order (left, right, root)

33
Q

What are breath-first and depth-first tree traversals?

A

Breath-first means visiting all nodes of a certain level before their children and depth-first is where an entire branch is visited before moving onto other branches

34
Q

What is Dijkstra’s shortest path algorithm?

A

An algorithm that works out the shortest path between two nodes using a weighted graph

35
Q

How is the cost of a path calculated in Dijkstra’s shortest path algorithm?

A

The cost is calculated by adding the weight of all edges along the shortes route