Topic 2 - Fundamentals of data structures Flashcards

1
Q

Define data structure?

A

Is the format used to efficiently store & organise a collection of related data items

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

Define array?

A

A data structure made up of a list of data elements that are the same data type or size

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

Example of a one-dimensional & two-dimensional array?

A

List

Table

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

Define text files?

A

Store data in humanly readable format

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

Define binary files?

A

Store data which is not in a humanly readable format, must be interpreted by a program or hardware.

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

Define static data structure?

A

Data storage method where the amount of data and memory allocated is fixed. e.g. an array

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

Define dynamic data structure?

A

Data storage method where the amount of data and memory allocated is varied to meet the needs of the application using it. e.g. a vector

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

One advantage of static data structures?

A

Memory addresses will be allocated at compile time, so will be fixed and contiguous, permitting faster access

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

One advantage of dynamic data structures?

A

Meets the needs of the application, effiecient use of memory

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

Define a queue?

A

Is used as a temporary storage space for data.

An abstract data structure which operates on FIFO.

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

Define a linear queue?

A

Is a FIFO data structure organised as a list of data

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

Define a circular queue?

A

Is a FIFO data structure organised in a ring formation

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

Define a priority queue?

A

Is similar to a regular queue except that each element is assigned a priority and the highest-priority are served first

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

Define a stack?

A

Is an abstract data type which uses FILO

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

What are the 3 operations which can be performed on a stack?

A
  • Push
  • Pop
  • Peek (or top)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What does the push operation do on a stack?

A

Adds items of data to the top of the stack

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

What does the pop operation do on a stack?

A

Removes the last item of data from the stack

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

What does the peek operation do on a stack?

A

Reads the top element in the stack without removing it from the stack

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

Define a graph?

A

Used to represent complex relationships such as computer interconnection drawings.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
What are the 4 parts to a graph?
V/N
E/A
W/UW
D/UD
A
  • Vertex/node
  • Edge/arc
  • Weighted/Unweighted graph
  • Directed/Undirected graph
21
Q

Define a vertex/node?

A

Is a value or node (with a circle around it)

22
Q

Define an edge/arc?

A

Is used to connect two nodes or vertices

23
Q

Define weighted to an unweighted graph?

A

Weighted - Is a graph that has labels on each edge/arc to indicate a data value.

Unweighted - is a graph that has no labels on each edge/arc to indicate its data value.

24
Q

Define directed and an undirected graph?

A

Directed - Is a graph where the direction of travel between vertices can only be one-way, as directed by the arrow.

Undirected - Is a graph where there is no set direction of travel from each node.

25
Q

Define an adjacency list?

A

Used to represent a graph by listing each node and the nodes directly connected to it

26
Q

State 2 comparisons of adjacency list & matrix?

A

Adjacency list stores details of graphs where an edge exists

Matrix stores details of all node adjacencies, where an edge exists as a 1 and where it doesn’t as a 0

27
Q

Was is the difference between a sparse and dense graph?

A

Sparse - With few edges, makes it faster and saves memory to use an adjacency list to store the data set.

Dense - With many edges, since all permutations of adjacencies are identified, it’s faster to store the data set as an adjacency matrix.

28
Q

Define a tree graph?

A

Is an abstract data type based on undirected graphs that don’t contain cycles. Each node can only be reached through one path.

29
Q
What are 4 parts of a tree graph?
R
P
C
L
A
  • Root
  • Parent
  • Child
  • Leaf
30
Q

Define a root in a tree graph?

A

Is the starting node that has no parents, all other nodes branch off from it.

31
Q

Define a parent in a tree graph?

A

This node has further nodes branching from it, which are called children.

32
Q

Define a child in a tree graph?

A

This node has nodes above it in the tree, which are called parents.

33
Q

Define a leaf in a tree graph?

A

This node has no nodes below it, is the last node on the tree edge

34
Q

Define a binary tree?

A

A tree structure where each node has a maximum of two child nodes is unordered since there are no relationships between a parent node and its child node.

35
Q

Define a binary search tree?

A

This is an ordered or sorted binary tree with the recursive relationships that for each node the left child is less than the parent node and the right node is more than the parent node.

36
Q

What are binary trees used for?

A
  • Routing the best path in a network, such as a telephone network.
  • Storing data in an easy-to-find, searchable format using standard tree traversal methods.
  • Storing hierarchal data, such as a dictionary tree for file management purposes.
37
Q

Define a hash table?

A

Is a data structure that stores data in an associative way.

The table is created using a hash function which maps a key to an index in an array to find the value of an array element.

38
Q

Define hash function?

A

Takes the data input known as a key and outputs an integer known as a hash value; this value maps the key to a particular index in the hash table.

39
Q

Define collision?

A

Is where two keys are applied to the hash function and create an identical hash value; hash functions are chosen with the aim of minimising the chance of collisions.

40
Q

Define linear probing?

A

Is where a key is assigned to the next available slot in the hash table if there is a collision.

41
Q

Define a linked list?

A

Is a linear data structure in which a group of nodes contain data and make use of a pointer to link with the next data element.

42
Q

Define separate chaining?

A

Is where the hash table index is a pointer to a linked list data structure that contains the data.

There are no collisions the linked list contains on element and the linked list will contain all of the collisions for a particular slot.

43
Q

Define a dictionary?

A

Is a data structure that contains a collection of ‘key-value’ elements where the data value is accessed by the associated data.

44
Q

What 3 operations can a dictionary perform?

A
  • Find: or search for a key returns the value
  • Add: or insert a key-value pair, unordered data
  • Delete: removes the key and its associated value
45
Q

Define a vector?

A

Vectors can automatically grow to store additional elements. The individual elements of a vector can be assessed efficiently via an index.
Similar to arrays

46
Q

What are the 3 ways vectors can be stored in?

A
  • List of real numbers
  • Functional interpretation
  • Geometric vector
47
Q

What is the list of real numbers in a vector?

A

e.g. 4-vector over R (R^4)

[1.2, 5.25, -4.3, 1.75]

48
Q
What is the functional interpretation in a vector?
0 = 1.2
1 = 5.25
2 = -4.3
3 = 1.75
A

S —> R

S = {0,1,2,3} R = {1.2, 5.25, -4.3, 1.75}