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.

Machine Level Stacks

COMP124 Lectures

A stack is a memory arrangement for storing and retrieving information. The order of storing an retrieving values from the stack can be described as LIFO (last in first out). The alternative would be a queue which is FIFO. Operations The operations on stacks are push and pop. Pushing a...

Read More

Seminar 3

COMP122 Seminars

Division by Zero in Java Generally, will give no error and the result Infinity. If you divide 0.0 by 0.0 then you will get the result NaN. Code Blocks Indentation is ignored by the compiler. You should use {} to properly define your blocks. switch statements This can we used...

Read More

Arrays - 2D Arrays

COMP108 Lectures

Suppose we have data of daily rainfall for a year. Find the maximum monthly average rainfall over a year. Lets assume that there are $d$ days in a month and $m$ months in a year. We could store rainfall data in a 2D array of size $m\times d$:   1...

Read More

Arrays - Finding Max/Min

COMP108 Lectures

If the dataset is sorted in descending order then the first number is the maximum number. This is excessive if set is unsorted. Pseudo-code Examples Maximum i = 1 m = 0 # only works for +ve numbers; see next example while i <= n do begin if A[i] >...

Read More

Nested Calls & The Call Stack

COMP124 Lectures

The CALL Instruction CALL does the following: Records the current value of the IP as the return address. Puts the required subroutine address into the IP, so the next instruction to be executed is the first instruction of the subroutine. The RET Instruction RET retrieves the stored return address and...

Read More

Subroutines

COMP124 Lectures

A subroutine is a section of code which can be invoked repeatedly as the program executes. Reason for Use Save effort in programming. Reduce the size of programs. Share code. Encapsulate or package a specific activity. Provide easy access to tried and tested code. Subroutines in Assembly Before we answer...

Read More

Assignment 1

COMP108 Seminars

This assignment is based around memory management. Paging/Caching Two level virtual memory system Slow memory contains more pages than fast memory called cache. Requesting a page: If a page is already in cache. Hit If page not in cache. Miss. In case of a miss, need to evict a page...

Read More

Imports, Packages & the Classpath

COMP122 Lectures

When you are writing a large Java program you can run into the problem of a cluttered name-space. This means that you are running out of fresh names for your classes. Packages A Java package is a collection of related classes. The full name of a Java class if of...

Read More

Loops

COMP122 Lectures

for Loops These are used to repeat a block of code a fixed number of times: for (initialisation; condition; update) { // stuff to repeat } Example Print the first 10 integers: for (int i = 1; i <= 10; i++) { System.out.println(i); } In this case the {} aren’t...

Read More

Methods

COMP122 Lectures

Methods are named code blocks. They: are defined inside a class definition. can have arguments and return value. They can return void. correspond to functions or procedures in other languages. Defining Methods modifiers returnType methodName (parameters){ // method body code here } modifiers determine how the method can be accessed....

Read More