1.2 Fundamentals of data structures Flashcards

1
Q

What is a data structure?

A

A data structure is any method used to store data in an organised and accessible format

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

What is an abstract data type?

A

A conceptual model of how the data is stored and the operations that can be performed upon them

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

Define queue

A

A data structure where the first item added is the first item removed

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

Define stack

A

A data structure where the last item added is the first item removed

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

What is a static data structure?

A

A method of storing data where the amount of data stored and the memory used to store it is fixed

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

What is a dynamic data structure?

A

A method of storing data where the amount of data stored and memory used to store it will vary as the program is being run

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

Define heap

A

A pool of unused memory that can be allocated to a dynamic data structure

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

Define stack frame

A

A collection of data about a subroutine call

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

Define call stack

A

A special type of stack used to store information about active subroutines and functions within a program

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

Define interrupt

A

A signal sent by a device or program to the processor requesting its attention

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

Define recursion

A

The process of a subroutine calling itself

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

Define the 3 different types of queue

A
  • Linear: a first in first out structure organised as a line of data such as a list
  • Circular: a first in first out structure implemented as a ring where the front and rear pointers can wrap around from the end to the start of the array
  • Priority: a variation of a first in first out structure where some data may leave out of sequence if it has a higher priority than other items
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Define graph

A

A mathematical structure which models the relationship between pairs of objects

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

Define vertex

A

An object in a graph, this can also be known as a node

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

Define arc

A

A join or relationship between two nodes, this can also be known as an edge

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

What is a weighted graph?

A

A graph that has a data value labelled on each edge

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

Define directed graph

A

A directed graph is a graph where the relationship between nodes is one way

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

Define unirected graph

A

A graph where the relationship between vertices is two way

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

Define adjacency list

A

A data structure that stores a list of nodes with their adjacent nodes

20
Q

Define adjacency matrix

A

A data structure set up as a two dimensional array or grid that shows whether there is an edge between each pair of nodes

21
Q

What are the differences between an adjacency list and an adjacency matrix?

A
  • An adjacency list only stores data when there is an edge so it requires less memory than an adjacency matrix which stores a value for every combination of adjacencies
  • In an adjacency matrix it is faster to check if an adjacency exists as all possible adjacencies are stored, whereas in adjacency list you have to check the whole list to see if it exists
  • Adjacency lists are more suitable for graphs with few nodes (sparse graphs) and adjacency matrices are more suitable for graphs with more nodes (dense graphs)
22
Q

Define tree

A

A data structure similar to a graph with no loops

23
Q

Define root

A

The starting node in a rooted tree structure from which all other nodes branch off

24
Q

Define parent

A

A type of node in a tree where there are further nodes below it

25
Q

Define child

A

A node in a tree that has nodes above it in the hierarchy

26
Q

Define leaf

A

A node that does not have any other nodes beneath it

27
Q

What is a binary tree?

A

A tree where each node can only have up to 2 child nodes attached to it

28
Q

What are the uses of a tree?

A
  • Can be used to store data that has an inherent hierarchical structure
  • Are dynamic so it is easy to add and delete nodes
  • Easy to search and sort with traversal algorithms
  • Can process syntax of statements so commonly used in compiling code
29
Q

Define hash table

A

A data structure that stores key / value pairs based on an index calculated from an algorithm

30
Q

Define key / value pair

A

The key and its associated data

31
Q

What is a hashing algorithm?

A

Code that creates a unique index from given items of key data

32
Q

How do hash tables function?

A

A hashing algorithm is carried out on the piece of data / key, which gives a value that acts as an index for that data item within the array of data. The same key can then be put through the hashing algorithm to look up and locate data within the hash table

33
Q

What are some uses of hashing algorithms?

A
  • Used to create indices for databases for quick storage and retrieval of data
  • Used to generate memory addresses where data will be stored
  • Used to encrypt data
  • Used to index keywords and identifiers so the compiler can easily access them during compilation
34
Q

Define collision

A

When a hashing algorithm produces the same index for two or more different keys

35
Q

Define clustering

A

When a hashing algorithm produces indices that are not randomly distributed

36
Q

Define load factor

A

The ratio of how many indices are available to how many there are in total

37
Q

Define index

A

The location where values will be stored, calculated from the key

38
Q

Define chaining

A

A technique for generating a unique index when there is a collision by adding the key / value to a list stored at the same index

39
Q

What are the criteria for a suitable hashing algorithm?

A
  • Numeric value generated to act as the index
  • Generates unique indices
  • Generates a uniform spread of indices to reduce clustering
  • Enough possible indices to store the volume of data
  • Balance issues of speed with complexity
40
Q

What are the methods for handling collisions?

A
  • Chaining: A list is created at that index which contains all key / value pairs which are to be stored at that index
  • Rehashing: The algorithm is run again or a new algorithm is run until a new, unique index is created
41
Q

Define rehashing

A

The process of running the hashing algorithm again when a collision occurs

42
Q

Define magnitude of a vector

A

One of the two components of its vector, refers to the size of the vector

43
Q

Define scalar

A

A real value used to multiply a vector to scale the vector

44
Q

Define the dot product

A

The process of combining 2 vectors to calculate a single number, for vectors (a,b) and (c,d), the dot product is given by ac + bd

45
Q

Define convex combination

A

A method of multiplying vectors that produces a resulting vector within the convex hull. For 2 vectors a and b, this is given by c (convex combination) = pa + qb, where p and q are both greater than 0, and p + q = 1

46
Q

Define vector space

A

A collection of elements that can be formed by adding or multiplying vectors together

47
Q

Define convex hull

A

A spatial representation of the vector space between two vectors