Data types, data structures and algorithms Flashcards

(39 cards)

1
Q

Properties of array

A

Static/size cannot be changed during processing
Element can be accessed directly
Contents stored contiguously in memory
Array contents are mutable
Holds data of a single type

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

Properties of lists

A

Dynamic (size can changed)
Can hold data of different types
Ordered (textbook)

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

Properties of tuples

A

Immutable / cannot be changed at runtime (other than this, same as a list: dynamic, can hold different data types, ordered)

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

What is a linked list (definition only)

A

Dynamic data structure, each node consists of a data and pointer, pointer gives location of next node

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

Properties of linked list

A

Dynamic/size can change during processing
Needs to be traversed until desired element is found
Contents may not be stored contiguously in memory (this has been corrected)

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

What is a record (textbook)

A

A record is a structure used within a database to store data by categories under key fields

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

Properties of records (3, textbook)

A

-A record is accessed through an attribute (or field).
-Unordered data structure
-Consists of different data types

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

Describe how to access the 2nd item in a linked list

A

-Go to the first position indicated by the start pointer
-From the first position, read the next pointer value

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

BFT vs DFT (i.e. suitability, performance etc.)

A

BFT is more efficient when data is closer to root, in general better time complexity
DFT is more efficient when data further down, memory requirement is linear, can be written recursively to aid understanding, in large trees may never return a value

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

Graphs vs trees (at least 4 differences)

A

Trees have one root node // graphs do not have a root node
Trees do not allow cycles/loops // graphs do allow cycles / loops
Trees store hierarchy // graphs have no hierarchy
Trees are always undirected // graphs can be directed
Trees are always connected // graphs can be connected or disconnected

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

Binary search trees (properties and advantages)

A

Each node can have a maximum of 2 child nodes
Nodes are ordered (left nodes less than the parent and right nodes greater)
The location to which a node is added depends on its order
Allows for faster searching (O(log n))
Inserting new nodes is faster
Do not need to sort the structure each time a new node is added

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

What are heuristics (AO1)

A

-Heuristics are used to reduce time taken to solve a problem
-It is a general ‘rule of thumb’ or an educated guess
-It finds a solution which is ‘good enough’ / close to the best solution
-Heuristic is a weight added to a node/decision
-E.g. Description of use such as in A* algorithm as estimate of distance to destination

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

How do heuristics help?

A

-Heuristics reduce the time complexity as every possibilities within a program does not need to be examined
-Avoid programs running indefinitely - in a computer game there could be too many possibilities so will terminate with a solution faster

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

Uses/applications of heuristics

A

-Heuristics are more appropriate with complex time-critical tasks - some aspects of game may require faster searching/decisions
-Heuristics are more appropriate with large-scale tasks - game could be large scale and AI algorithms may need to be shortened
-Games are not life-critical, so a good answer is likely enough, a perfect answer is not necessarily required
-Used in AI when the exact steps cannot be pre-programmed and decisions need making

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

Limitations/disadvantages of heuristics?

A

-Heuristics require skill to implement effectively
-Due to time-saving, they are not always accurate, the solution e.g. shortest path might not be the most efficient

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

What is meant by a character set?
What is the number of values represented by n bits?

A

-Number of values represented with n bits is 2^n
-Character set means all the characters a computer can understand (1), may include control characters (1), binary code equates to symbols (1), e.g. ASCII (1)

17
Q

What is Unicode?

A

-Each character is represented by 1-4 bytes
-Supports very large number of characters
-Backward compatible with ASCII

18
Q

What is a D-type flip flop?

A

Stores a value of one bit when signal is given (specifically on the rising edge according to my fwends, attributions: Toba, Oliver, Yusra)

19
Q

Purpose of head pointer

A

To identify the first item/element

20
Q

Purpose of tail pointer

A

To identify the next free space

21
Q

Time complexity for traversing linked list

A

O(n) or linear complexity

22
Q

Time complexity of recursive algorithm?

23
Q

Data structure for BFT

24
Q

Data structure for DFT

25
Linear search time complexity
Best: O(1) Average: O(n) Worst: O(n)
26
Linear search space complexity
O(1)
27
Binary search time complexity
Best: O(1) Average: O(log n) Worst: O(log n)
28
Binary search space complexity
O(1)
29
Bubble sort time complexity
Best: O(n) Average: O(n^2) Worst: O(n^2)
30
Bubble sort space complexity
O(1)
31
Insertion sort time complexity
Best: O(n) Average: O(n^2) Worst: O(n^2)
32
Insertion sort space complexity
O(1)
33
Merge sort time complexity
Best: O(n log n) Average: O(n log n) Worst: O(n log n)
34
Merge sort space complexity
O(n)
35
Quick sort time complexity
Best: O(n log n) Average: O(n log n) Worst: O(n^2)
36
Quick sort space complexity
O(log n)
37
BFT vs DFT (algorithm itself)
**AO1: Knowledge and Understanding Indicative content** * Breadth first takes first value then visits all nodes connected to it. It then takes all nodes connected to those nodes. * Depth first goes to the left node, this becomes a new tree. It continues going to the left until a leaf. It then returns this, then goes right and repeats from the start. Follow left, follow right, take root.
38
Explain why a quicksort is known as a divide and conquer algorithm
* decomposing data sets into smaller subsets * and then sorting each split subset * until each subset is sorted * and then combining the subsets to provide a solution
39
State the purpose of the constructor
To create an instance of an object from a class