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.
A variable is a named memory location that can be changed during the program’s execution. It has three properties: A type. A value. A name or identifier. Identifiers Not all identifiers are valid. They can be an sequence of alphanumeric characters, $ and _ unless: They start with a number....
Java is strongly typed. This means that all types consist of a value and a type. Types of Types There are two different types of type in Java. Primitive int, byte, short and long float, and double char boolean Composite string Arrays e.g. int[] Literals Literal values are the actual...
Powers To find the time complexity of an algorithm look at the loops: count = 0 for i = 1 to x do for j = 1 to y do for k = 1 to z do count = count + 1 For this loop the time complexity is $O(xyz)$....
Efficiency matters as we want to make more ambitious code to leverage increases in computational power. If we didn’t optimise code then we’d be wasting resources. Time Complexity Analysis Timing execution time is not enough as it is not reproducible and wastes time. We should identify some important operations and...
Writing machine code direct in binary would be too difficult and error prone. However we can do it using something called assembly language. Each assembly language statement corresponds to a single machine instruction. Opcodes are specified using mnemonics (jmp, mov) Registers are given names and addresses are specified using labels....
A Typical Instruction Set Data Transfer Load, store, push, pop. Arithmetic Add, subtract, multiply, divide. Logical AND, OR, NOT, shift rotate. Test and Compare Control Flow Conditional jump, unconditional jump, subroutine call and return. Other All high-level language code must be translated into these basic machine code instructions. The difference...
Variables Testing equivalence of two floating point numbers should be done as follows to account for error: double_1 == double_2 // Returns False Math.abs(double_1 - double_2) < 0.000001; // Returns True To use the maths library for mathematical constants use the following to import: import java.lang.Math You would use the...
The CPU This is a block diagram of a CPU: CU - Control Unit Fetches instructions and works out what to do with them. Controls the flow of execution. ALU - Arithmetic Logic Unit Performs operations on bit patterns in order to complete mathematical and logic operations. Registers Memory on...
The Von Neumann Model The input device is used to load programs and data into memory. The CPU fetches program instructions from memory, processing the data and generating results. The results are sent to an output device. Systems The CPU is connected to the rest of the components by the...
This tutorial focuses on the answers for the first tutorial on numbers and polynomials. Question 5 We are given the following numbers which can be expressed by the way of the following polynomials: \(\begin{align} 1567\rightarrow p(x)=&x^3+5x^2+6x+7\\ 3791\rightarrow q(x)=&3x^3+7x^2+9x+1 \end{align}\) By multiplying them together we get the following polynomial: \(\begin{align} p\cdot...