Component 2 Flashcards

1
Q

What is a cache hit?

A

A cache hit is when the data/instructions are found in cache

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

What is a compulsory miss?

A

The first time data is fetched there is no way it is in cache so it has to be missed

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

What is a capacity miss?

A

When the data/instruction in cache has been evicted as it is full

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

Describe the prefetching algorithm

A

Instructions are prefetched from RAM to cache before it is actually needed which will reduce time if the user then wants that bit of data or the instruction. This is used to combat compulsory misses

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

What is one advantage and one disadvantage of the prefetching algorithm?

A

One advantage is that it may lower CPU processing time if it prefetches the right thing, however if it doesn’t call the right thing it then has to wait to remove that and then bring the needed data in which would slow the overall process down

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

List 2 eviction algorithms and how they are used

A

1) Clairvoyant algorithm uses statistical analysis of the users past to predict what they may need so it can be swapped in
2) LRU (Least recently used) which removes the least used items in cache, however may be hard to implement
3) Random replacement, which simply removes an item from cache at random

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

Give two advantages of caching

A

1)Allows faster response times as data doesn’t need to be read from the disk
2)It reduces the load on the system or web server if it is web caching

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

What is the purpose of using documentation, give an advantage and a disadvantage

A

Documentation is used to allow other developers to follow the code more easily and understand the preconditions for a certain function. A disadvantage of this is that it could take a long time to write

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

What is passing by reference?

A

Passing by reference is where a specific memory address is passed into a function which is not a copy, so the original value of the variable is changed within the function

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

What is passing by value?

A

Passing by value is where a copy of the value is made in memory of the original variable so the copy is sent meaning the original value isn’t changed

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

List 3 types of abstraction and what they are

A

1)Representational = Representing real world items like a station with a more simple object like a circle
2) Generalisation = Generalising an object into it’s fundamental properties
3) Information hiding = Hiding info from the user that they don’t need to see
4) Functional abstraction = Not knowing how all of the functions work, eg) .sort() or .randint()
5)Procedural abstraction = Using reusable procedures (Modularisation)
6)Data abstraction = Using complex data structures like stacks instead of many variables
7) Problem abstraction = Generalising and removing unwanted details

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

Give 2 advantages of abstraction

A

It allows a more efficient design process, reduces time needed to code and debug and saves system resources

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

Give a disadvantage of abstraction

A

Too much abstraction can simplify the problem too far and so it may be too simple

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

What is abstraction?

A

Abstraction is the process of removing unneeded details from the problem making it easier to solve

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

What is decomposition?

A

Decomposition is the process of breaking down a problem into larger subproblems allowing them to be solved easier

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

Give one disadvantage of decomposition

A

Potentially more resources used as return addresses need to be stored in memory

17
Q

What is parallel processing

A

Parallel processing is where two tasks are run simultaneously on two different processors

18
Q

What is concurrent processing

A

Concurrent processing is where you give small chunks of processor time to each task so that it creates the illusion that the processes are running simultaneously but in reality there are just doing small chunks of it at separate times

19
Q

Give one advantage and one disadvantage of concurrent processing

A

An advantage is that it allows the processor to seem like it’s executing two tasks at once, however, it may cause race conditions where two threads want the same bit of data at the same time, we can fix this by locking a thread temporarily while the other one accesses the data. However, this may cause a deadlock where two or more tasks are waiting for each to complete and so neither gets to use the data

20
Q

Describe the process of a linear search

A

We start at index 0 and then check each item at index i in turn so we then check i + 1 then i + 2 so i+n for all n up to the end

21
Q

Describe the process of a binary search

A

We first pick the midpoint with the formula of floor(start+end/2) or (start+end)//2 where // means integer division. Start and end are the indexes of the start and end of the list. Then we compare the item we want to the item found at the midpoint and disregard the half we don’t want and then update the start and end positions then repeat the process

22
Q

Describe the process of a bubble sort

A

We start at index 0 and then compare each adjacent item in order and see if they need swapping, then swap them, repeat this across the whole list until no more swaps need to be made on a complete pass

23
Q

Describe the process of an insertion sort

A

It inserts each item into it’s correct position so we start in it’s original position then keep swapping it down the list until we find it next to an item that is less than it, then we know it’s in the right place. This means we start at the far end of the list.

24
Q

Describe the process of a quick sort

A

It will pick a random pivot point and move each item in the list until it is on the right side of that pivot point. This process is then repeated with different pivots until all items are in order.

25
Q

Describe the process of a merge sort

A

A merge sort will repeatedly split the list in two until we have many lists each with only one item so each item in the original list has it’s own list. Then at each branch we compare the first item in each list with the first item in the list on the other branch and sort them into the next list, repeat with each item on each branch until both those branches are combined, then work down the tree to combine the branches until the list is sorted

26
Q

Describe how Dijkstra’s path-finding algorithm works

A

Given a start node it will calculate the weighting to visit each node linked to the node it’s currently at, once this is done mark the current node as visited., Then go to the node with the lowest cost that isn’t visited already, repeat this process visiting each linked node and calculating costs until we have visited all the nodes in the list

27
Q

Describe how the A* algorithm works

A

Similar to Dijkstra’s except we have some heuristic value h so that the cost g is added to it to get the f value (f=g+h), and instead of visiting the node with the lowest calculated cost, we visit the one with the lowest f value that hasn’t already been visited, and we also halt when we have visited the target node were looking for

28
Q

What is the time complexity of all the algorithms on the specification?

A

Linear search - O(n)
Binary Search - O(logn)
Bubble sort - O(n) at best, O(n^2) on average because of two loops
Insertion sort - O(n^2)
Quick sort - O(logn) on average and O(n^2) worst case
Merge Sort - O(nlogn)
Dijksta’s - O(E+logV)
A* - O(b^d) where b is the branch depth and d is the depth of the goal node