Skip to content
UoL CS Notes

Home

This website houses notes from my studies at the University of Liverpool. If you see any errors or issues, please do open an issue on this site's GitHub.

Vectors, Matrices & Graphical Effects

COMP116 Tutorials

Vectors Movement 3D vectors are ordered like so: \[\langle x,y,z\rangle\] With $z$ being the vertical component. In 4D a 4$^{th}$ dimension is used for time: \[\langle x,y,z,t\rangle\] Size Here is an example: \[\vert\vert\langle1,-2,2,-4\rangle\vert\vert\] You will generally be expected to find the euclidean distance. This example will give: \[\sqrt{25}=5\] Spaces Suppose...

Read More

Variable Addressing & Arrays

COMP124 Lectures

Every variable is just a location in memory at which a value is stored. Pointers will refer to the value of a memory location but sometimes we want it’s address. Variable Addresses in Assembly In assembly language we can get the address of a variable with the LEA (load effective...

Read More

Sheet 2

COMP124 Labs

Using Local Variables Variables will be declared in the C portion of the code and take up the following amount of space: int - 4 bytes char - 1 byte Strings will take as many bytes and characters. Example of Common Assignments int num = 0; signed in num =...

Read More

Partial Derivatives & Multi-variable Functions

COMP116 Lectures

Consider a function such as: \[z=-(3x^2+2y^2+xy)\] What are the values of $x$ and $y$ which maximise $z$? Are there any such values? Partial Derivatives For the prior function: We need values of $x$ and $y$ which maximise $z$. We know $x$ to maximise $z$ when $y$ is fixed. We know...

Read More

Arrays - Binary Search

COMP108 Lectures

This method is a moire efficient way of searching but only when the sequence of numbers is sorted. Input A sequence of $n$ sorted numbers in ascending order and a target number key. Method Compare key with number in the middle. Then focus on only the first half or the...

Read More

Arrays - Sequential Search

COMP108 Lectures

For arrays, out of bounds means any index that is not in the range of the index. When using arrays in pseudo code the following notation will be used: arrayName[index] Arrays in the notes will also be indexed from 1. Sequential/Linear Search Input $n$ numbers stored in an array A[1..n],...

Read More

Loops

COMP124 Lectures

Iteration can be achieved by jumping backwards in the code. We need to ensure that we don’t end up in an infinite loop. A while loop simply repeat while a given condition is true. while Loops This codes calculates the 1000th Fibonacci number: while (fib2 < 1000) { fib0 =...

Read More

Register Flags, Jumps & Conditions

COMP124 Lectures

The Flags Resgister We often want to query the effect of a previous instruction. The status of an operation is recorded in the flags register. It contains these flags and others: S - Sign Indicates whether result is +/-. Z - Zero Indicates if result is zero or not. C...

Read More

Conditionals

COMP122 Lectures

Imagine a program that does the following: graph TD i[Get Input] i --> p[Positive?] p -->|yes| Process p -->|no| Complain Process --> b[ ] Complain --> b if-else Statements in Java if (condition) { // do stuff } else { // do something else } This means that if the...

Read More

Arrays

COMP122 Lectures

Arrays are variable storing fixed-length lists of values with the same type. For example we can have an integer array called count and type int[]. Array Types For every type x there is a corresponding array type x[]. Declaring Array Variables int[] numbers; double[] reals; boolean[] truthValues; Creating Arrays In...

Read More