Component 1 Flashcards

1
Q

What is the opcode and operand?

A

The opcode is the first part of a binary instruction and is the actual operation we need to do such as ADD, STA, DAT or whatever it may be. The operand is the second half of the binary instruction and is the actual data to be dealt with say ADD 0011 would be the instruction to add 3 to the current value of the ACC

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

What is the purpose of DAT in assembly?

A

DAT is used to name a data location, sort of like naming a variable in a high level language apart from the fact that it is often done at the end of the program

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

What is the purpose of STA, LDA and BRP in assembly language?

A

STA = Store and will store the contents of the value of the ACC in the given memory address in the operand. LDA = Load what is referenced by the given memory address into the accumulator and BRP = Branch is positive or negative meaning jump to the address given if the accumulator value is >= 0

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

What does it mean for a data structure to be mutable?

A

A mutable data structure is one that can have it’s contents changed during runtime

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

Is an array static or dynamic and what do they both mean?

A

An array is static meaning it’s length cannot be changed during runtime and dynamic means the length of the data structure can be changed during runtime

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

Give an advantage of an immutable data structure and an example of one

A

It has no opportunity to introduce runtime errors if the contents of the data structure cannot be changed. An example of this is a tuple

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

What is immediate addressing?

A

Immediate addressing is where the actual value of the operand is the bit of data that we want

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

What is direct addressing?

A

Direct addressing is where the opcode is a pointer to a memory address which contains the value of the data that we want

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

What is indirect addressing?

A

Indirect addressing is where the operand is a pointer to a memory location which is then another pointer to a final memory location which contains the data or instruction that we want

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

What is an advantage of indirect addressing?

A

It allows us to use more memory addresses than with direct addressing as there may be more bits available

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

What is indexed addressing?

A

Indexed addressing is where the operand value + some constant in the index register is the pointer for the memory address that we want

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

What is an advantage of indexed addressing?

A

It is very useful for large data structures like arrays as we only need to specify the start with the constant in the index register

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

What is the time complexity of searching through, an array, a list

A

They are both O(n) normally as we check each individual element but O(1) at the best case which is when we know where the value we are looking for is

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

What is the time complexity of a binary search

A

It is O(logn) as it uses a divide and conquer algorithm

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

How does a hash table work?

A

An input is run through a hashing algorithm to give a unique hash which then corresponds to a given index in an array which the data can then be put into

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

What is the time complexity of a hash table and why?

A

O(1) constant as it only takes a constant amount of time to run an input through a hash table which gives the index we need. This only changes to O(n) if we have collisions as we would need to check through the overflow list

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

What are collisions in a hash table?

A

Collisions are where two inputs with two distinct hashes correspond to the same array index meaning we need to put two items into one array index which isn’t possible, so we fix this by creating an overflow list which any overflows are put into

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

What is the algorithm for adding and removing from a hash table?

A

Adding an item: first we run the input through a hash algorithm and correspond that to an array index, then we check if that array index is free and if it is then we simply add that value to the given index. If it isn’t then we go to the overflow array and add it to the next free index in that array.

Removing an item: first we run the input through the hash algorithm and get a corresponding array index, then we check if the value in that index is the one we want to remove and if it is then simply remove it, if not we start traversing the overflow array until we find the one we want

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

What is a stack?

A

A stack is a last in first out data structure where items are pushed to the top of the stack and popped off the top, and so only the top of it can be accessed at any given time.

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

What is a queue?

A

A queue is a first in first out data structure meaning, you enqueue items to the back of a queue, and dequeue them from the front. This means it consists of a head and tail pointer which indicate the back and front a queue

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

What are the applications of a stack?

A

Anything that requires stepping back like the undo function or back button on a web browser, also a function call so we know which line number to return to

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

What are the applications of a queue?

A

Print queues, or process scheduling in the CPU

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

What is a graph?

A

A graph is a data structure consisting of vertices and edges where each node is connected with a pointer to any number of other nodes, a node with only one connection is known as an edge, we can have undirected graphs where connections go both ways, or directed where you can only traverse between two nodes in one way

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

What is a weighted graph?

A

A graph in which traversal between nodes has a value associated with it often called a weight or a cost, this could represent distances if we’re considering nodes as locations

25
Q

How would you implement a graph in pseudo code?

A

Edges{(A,B),(A,C),(B,A),(C,A)…} which is a dictionary showing all the possible paths between nodes, showing them BOTH ways
OR
With an adjacency matrix where each element like [1,2] shows whether that path exists in the graph

26
Q

What is the difference between breadth first and depth first traversal?

A

Breath first traversal visits the neighbours of the root node first and then all the ones parallel to the node currently being visited, this uses a queue to implement
Depth first traversal explores all the way down a branch first before going back up to explore all the way down another branch, this uses a stack

27
Q

What is the algorithm for a breadth first search?

A

1) Set the root node as the current node
2) Add the current node to the list of visited nodes if it’s not already there
3) Visit every node linked to that current node and enqueue
4) Dequeue the first node and set the removed node as the current node
5) Repeat steps 2->5 until there’s none left to visit
6) Output the visited nodes

28
Q

What is the algorithm for the depth first search?

A

1) Set the root node as the current node
2) Add the current node to the list if it’s not already on it
3) For every edge connected to the current node, push it onto the stack
4) Pop off the top item, and set it to the current node
5) Repeat from step 2 until there’s no nodes left
6) Output all the visited nodes

29
Q

What is a gay tree?

A

A tree is a data structure similar to a graph but each parent node can only have no, one or two child nodes and no cycles can exist, and all paths are directed meaning there exists some distinct parent node.

30
Q

What is a binary search tree?

A

A binary search tree is a tree such that all nodes left of a given node are less than that node, so everything less than the root node is less than it and everything right of the root node is greater than it.

31
Q

What is the use of a tree and binary search tree?

A

A tree is used, for file directories or path finding, essentially anything with a hierarchical structure. A binary search tree can be used for efficient searching in a data base, wireless networking or OS scheduling

32
Q

What are the 3 types of traversal of a binary tree and how do they work?

A

1) Pre order which visits the root node, left branch then right branch- dot goes left of node
2) In order which visits left branch, root node then right branch - dot goes under node
3) Post order which visits left branch, right branch then root node - dot goes right of node

33
Q

What are the 4 ACID rules

A

Atomicity - A change is either completely done or not at all done to a database

Consistency - All changes must retain the overall state of the database

Isolation - A transaction must not be interrupted by other transactions

Durability - Once a change is done, it must not be lost due to system failure

34
Q

What are the conditions for first normal form?

A

All field names must be unique, all values in the fields must be atomic, meaning each field must only have one piece of data in it. The values in each field must be of the same type (In the same domain). No two records can be identical and each table needs a primary key

35
Q

What are the conditions for second normal form?

A

The database must already be in first normal form and also must have removed all partial dependencies which are where one or more fields depend only on only part of the primary key

36
Q

What are the conditions for third normal form?

A

Already in second normal form and removed any transitive dependencies, meaning all fields must be dependant on the primary key

37
Q

What is polymorphism?

A

Polymorphism is where one process runs on two different sets of inputs and so will give 2 different outputs say adding two values together with a set of integers and a set of strings, same process, different inputs and outputs

38
Q

What is listed in the data protection act?

A
  • Personal Data must be fairly and lawfully processed
  • Personal data must be obtained for specific purposes
  • Data must be adequate and relevant
  • Data must be accurate and up to date
  • Data must not be kept longer than required
  • Dat must be handled in a secure way
39
Q

What is listed in the computer misuse act?

A
  • Prohibits access to computer systems without prior permission
  • Prohibits unauthorised modification to computer systems
40
Q

What is listed in the copright design and patents act?

A
  • Protects all intellectual
    -Automatically applied to original works
    -Expires 25 to 70 years after authors death
41
Q

What is listed in RIPA? (Regulation of investigatory powers act)

A
  • Public organisations are able to gain access to things like phone lines to monitor someone but only with good and lawful intent
42
Q

What is an issue with RIPA?

A

Some may consider it an invasion of privacy as it allows corporations to access personal information that they shouldn’t have access to and it raises the question of what are they using this data for

43
Q

What are the two types of memory management within RAM?

A

Paging, this is where we split up memory into discrete and evenly sized chunks so each bit of data can be put into each page where it will fit. To access these the OS indexes a page table to find the index of the page we want.

Segmentation which is where memory is split up into uneven chunks called segments which are split up into logical divisions given the current data we need to store. This means we avoid splitting up programs which generally slows things down as we have to rebuild them when calling from memory. The name also implies that we can segment functions into segments so that if two programs need it they can both access it easily

44
Q

What is disk thrashing

A

This is when memory is swapped too quickly around using paging, segmentation or Virtual memory and so the CPU cannot get the data it needs when it needs it and so the computing freezes

45
Q

What is an interrupt?

A

An interrupt is a command given to the CPU to halt whatever it is currently doing to execute the task it is about to be given. This means stopping the FDE cycle using the ISR (interrupt service routine)

46
Q

How does the ISR work?
When is it used?

A

The current state of all registers are added to a stack frame
The registers are all wiped and the PC gets updated with the address of the interrupt
The interrupt is then executed on the CPU as any normal cycle
The registers are then all cleared and the previous states are loaded from the stack frame
The FDE cycle can then continue as normal

It is used when we have a job that is of a higher priority than the one being executed. This is decided by its place in the priority queue as all incoming jobs are added to the priority queue

47
Q

What is the round robin?

A

It is a scheduling algorithm where each job is given a set time slice (a quantum) and if it isn’t complete in this time then it gets added to the back of the queue and repeat until it is done. If it is completed then it is removed from the queue

48
Q

What is first come first served in scheduling

A

This is simply a scheduling algorithm where the job at the start of the queue is completely run first and as soon as that is done we do every successive job in the priority queue

49
Q

What is multi level feedback queues

A

This is where we can use multiple cores and so we have multiple queues waiting so we can swap jobs between queues to optimize it

50
Q

What is shortest job first?

A

This is a scheduling algorithm where we look for the job with the shortest time and run this first on the CPU then do every job in order of increasing job time.

51
Q

What is shortest remaining time?

A

It is a scheduling algorithm where we look at the priority of the job and how long it has left and choose which one to execute based on it’s priority and time remaining

52
Q

List 2 eviction algorithms and how they work

A

1) Clairvoyant, this uses statistical analysis to remove the most optimal set of instructions from L1 cache if we don’t need it
2) LRU (Least recently used) This simply removes the instructions that are used the least as we don’t need them
3) Random replacement which just randomly picks one instruction to remove from cache which is incredibly inefficient

53
Q

Describe the FDE cycle in detail

A

In the fetch phase:
1)The address in the PC is copied to the MAR
2)It is then sent over to memory via the address bus
3)The control unit sends a read signal via the control bus
4)The result is then sent over the data bus to the MDR
5) It is removed from the CIR and the PC is incremented by one for the next instruction

In the decode phase:
1) The instruction is made up of the opcode and operand
2) This is loaded into the accumulator depending on the contents of the opcode and operand

Execute phase:
1) The data is then sent across the data bus to the MDR if it needs to be stored into memory
2) If not it is sent to the accumulator and the cycle can start again

54
Q

What is the difference between Harvard and Von Neumann architecture

A

Von Neumann is where all instructions and data are stored physically together. A single control unit follows the FDE and cycle and only one instruction at a time due to one set of buses

Harvard Architecture is where Instructions and data are physically separated and so 2 sets of buses are needed. This then means reading and writing can be done more efficiently as we can do it at the same time

55
Q

What is an advantage of Harvard architecture

A

Harvard can read and write to memory at the same time and so is incredibly quick given no interrupts and so is useful in an embedded system

56
Q

What is a CISC and RISC processor?

A

A complex instruction set computer (CISC) is an instruction set with relatively complicated instructions such as multiply, each CISC command corresponds to multiple RISC commands.

A reduced instruction set computer (RISC) has only the fundamental instructions such as load, add and store and so each RISC command corresponds to one machine code command

57
Q

Give 1 advantage and 1 disadvantages of RISC and CISC

A

CISC:
+ Less RAM is required since code is shorter
+ Often used in x86 as it has multiple addressing modes
-They use much more energy as pipelining isn’t possible as some instructions need multiple cycles

RISC:
+Each instruction only needs 1 cycle to complete
+The physical board is a lot smaller
-The compiler has to do more work
-More RAM is required to store the code

58
Q
A