Data Structures Flashcards

1
Q

What is an array?

A

An ordered, finite set if elements of a single type

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

What type of array is a linear array?

A

A 1D array

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

How can you visualise a 2D array?

A

As a spreadsheet or table

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

How can you visualise a 3D array?

A

As a multi-page spreadsheet

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

What is a record also known as?

A

A row in a file

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

What is a record made up of?

A

Fields

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

How can you select a field from a record using pseudocode?

A

record.Name.fieldName

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

What is the definition of a list?

A

A data structure consisting of a number of items in which the items can occur more than once

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

What is the main difference between arrays and lists?

A
  • Lists can store data non-contiguously whereas arrays store data in order
  • Lists can store data of more than one data type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a tuple?

A

An immutable, ordered set of values of any type

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

What is the difference between a tuple and array?

A

Tuples are initialised using regular brackets instead of using square brackets

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

What is a linked list?

A

A dynamic data structure used to hold an ordered set of items which are not stored in a contiguous location

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

What is the name given to the items in a linked list?

A

Nodes

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

What does each item in a linked list contain?

A

A data field and another address field called link/ pointer

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

What is a data field in a linked list?

A

A field that stores the actual data

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

What is a pointer field in a linked list?

A

A field that contains the address of the next item in the list.

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

What is a directed graph?

A

A graph in which the edges can only be traversed in one direction

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

What is a graph?

A

A data structure consisting of a set of vertices/ nodes connected by edges/ arcs

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

What is an undirected graph?

A

A graph in which the edges can be traversed on both directions

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

What is a weighted graph?

A

A graph in which the arcs/ edges have a cost to traverse

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

Give two ways of representing graphs so that they can be understood by computers

A
  • Adjacency Matrix
  • Adjacency List
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What are the advantages of Adjacency Matrix?

A
  • Convenient to work with
  • Easy to add new nodes to
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What are the advantages of using an Adjacency List?

A

Space for large sparse networks

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

What is a stack?

A

A LIFO (last in first out) data structure, where items can only be removed from and added to the top of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Give an example of when a stack may be used
- Back button in a web page - Undo buttons
25
What is a queue?
A FIFF (first in first out) data structure where items are added to the end of the queue and removed from the front of the queue
26
What is a tree?
A data structure which has a root node and child nodes connected with branches
27
What is a node?
Any item in a tree
28
What is an edge?
Connection between two nodes
29
What is the root node?
The node which doesn't have any incoming nodes, at the top of the tree
30
What is a child?
Any node which has an incoming edge
31
What is a parent?
Any node which has outcoming edges
32
What is a subtree?
A section of the tree which consists of a parent and all the children of that parent
33
What is a leaf?
A node which has no children
34
What is a binary tree?
A type of tree in which each node has a maximum of two children
35
What is the purpose of a binary tree?
Used to search for values quickly
36
What is a hash table?
An array which is coupled with a hash function
37
What is a collision (hashing)?
Where two inputs result in the same hashed value
38
What properties does a good hashing algorithm have?
Low chance of collision and must be fast
39
What is pre-order traversal?
Traverse from the root node, followed by the left subtree then the right subtree
40
What is in-order traversal?
Traverse the left subtree, the root node then the right subtree
41
What is post-order traversal?
Traversal algorithm in which you traverse the left subtree, the right subtree followed by the root node
42
What does the operation isEmpty() do? (Lists)
Checks if the list is empty
43
What does the operation append(value) do? (Lists)
It adds the given value to the end of the list
44
What does the operation remove(value) do? (Lists)
Finds the first instance of the given value and removes it
45
What does the operation search(value) do? (Lists)
Searches for the given value in a list
46
What does the operation length(value) do? (Lists)
Returns the length of the list
47
What does the operation index(value) do? (Lists)
Returns the index of a value in the list
48
What does the operation insert(position, value) do? (Lists)
Adds the value to the position in the list
49
What does the operation pop() do? (Lists)
Returns and removes the last value in the list
50
What does the operation pop(position) do? (Lists)
Returns and removes the value at the given position in the list
51
What does the operation isEmpty() do? (Stacks)
Checks to see if the stack is empty
52
What does the operation push(value) do? (Stacks)
Adds the given value to the top of the stack
53
What does the operation peek() do? (Stacks)
Returns the top value of the stack
54
What does the operation pop() do? (Stacks)
Returns and removes the value at the top of the stack
55
What does the operation size() do? (Stacks)
It returns the size of the stack
56
What does the operation isFull() do? (Stacks)
Checks to see if the stack is full
57
What does the operation enQueue(value) do? (Queue)
Adds the given vale to the queue
58
What does the operation deQueue(value) do? (Queue)
Removes the item from the end of the queue
59
What does the operation isEmpty() do? (Queue)
Checks to see if the queue is empty
60
What does the operation isFull() do? (Queue)
Checks to see if the queue is full