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.

Regular Expressions (Regex)

COMP122 Labs

Consider the following text as a test for regular expressions: It is a period of civil war. Rebel spaceships, striking from a hidden base, have won their first victory against the evil Galactic Empire. During the battle, Rebel spies managed to steal secret plans to the Empire’s ultimate weapon, the...

Read More

Input & Output (I/O)l - 1

COMP122 Labs

Due to the large number of I/O classes in java.io.Files, there is a class called: java.nio.Files This class consists of several static function calls that cater to common use cases. You should look in this class before looking elsewhere. Reading from File A classic approach to reading from a text...

Read More

Streams

COMP122 Lectures

Streams are an endless flow of data from a source to a destination: graph LR Source -->|write| 010010 010010 -->|read| Destination Streams are objects. There are different classes for various types of sources and destinations. Streams as Object The standard library java.io implements streams in an object-oriented way. The InputStream...

Read More

Files

COMP122 Lectures

File Handles This is an object that represents a file on the disk (a path in the file system). java.io.File is used to represent files and provides methods to interact with the file system. You can call the following methods on a File: Deleting Renaming Check if it exists: Check...

Read More

Synchronised Methods

COMP124 Lectures

This method extends the example in the last lecture. Java uses the American spelling: synchronized. Synchronised Method class Buffer { private int v; private volatile boolean empty = true; public synchronized void insert (int x) { while (!empty) ; // null loop empty = false; v = x; } public...

Read More

Producer-Consumer Problem

COMP124 Lectures

A producer process and a consumer process communicate via a buffer. Producer Cycle: Produce item. Deposit in buffer. Consumer Cycle: Extract item from buffer. Process the item. There can be many producers and consumers, sometimes in a chain. Issues We have to ensure that: Producer cannot put items in a...

Read More

Spectral Methods - SVD & Image Compression

COMP116 Lectures

An image can be represented as a matrix where each cell used 24 bits to encode the colour as RGB. To compress it we can use the following method: Given an $H\times W$ image $P$, let $M$ be the corresponding matrix. $M$ will not typically be a square matrix. Exploiting...

Read More

Greedy Algorithm - 3 - Single-Source Shortest Paths

COMP108 Lectures

Single-Source Shortest Paths Consider a directed/undirected connected graph $G$: The edges are labelled by weight. Given a particular vertex called the source: Find shortest paths from the source to all other vertices. Example Undirected connected graph $G$: graph LR a ---|2| b b ---|3| c a ---|3| c b ---|2|...

Read More

Greedy Algorithm - 2 - Minimum Spanning Tree

COMP108 Lectures

Minimum Spanning Tree (MST) Given an undirected connected graph $G$: The edges are labelled by weight Spanning tree of $G$: A tree containing all vertices in $G$. Minimum spanning tree of $G$: A spanning tree of $G$ with minimum weight. Example Undirected connected graph $G$: graph LR a ---|2| b...

Read More