Component 2 Flashcards
(28 cards)
What is a cache hit?
A cache hit is when the data/instructions are found in cache
What is a compulsory miss?
The first time data is fetched there is no way it is in cache so it has to be missed
What is a capacity miss?
When the data/instruction in cache has been evicted as it is full
Describe the prefetching algorithm
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
What is one advantage and one disadvantage of the prefetching algorithm?
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
List 2 eviction algorithms and how they are used
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
Give two advantages of caching
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
What is the purpose of using documentation, give an advantage and a disadvantage
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
What is passing by reference?
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
What is passing by value?
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
List 3 types of abstraction and what they are
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
Give 2 advantages of abstraction
It allows a more efficient design process, reduces time needed to code and debug and saves system resources
Give a disadvantage of abstraction
Too much abstraction can simplify the problem too far and so it may be too simple
What is abstraction?
Abstraction is the process of removing unneeded details from the problem making it easier to solve
What is decomposition?
Decomposition is the process of breaking down a problem into larger subproblems allowing them to be solved easier
Give one disadvantage of decomposition
Potentially more resources used as return addresses need to be stored in memory
What is parallel processing
Parallel processing is where two tasks are run simultaneously on two different processors
What is concurrent processing
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
Give one advantage and one disadvantage of concurrent processing
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
Describe the process of a linear search
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
Describe the process of a binary search
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
Describe the process of a bubble sort
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
Describe the process of an insertion sort
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.
Describe the process of a quick sort
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.