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.

Arrays & Debugging in C

COMP281 Lectures

Arrays An array consists of contiguous memory locations: The highest address corresponds to the last element. The lowest address corresponds to the first element. Declaring Arrays Arrays can be declared like so: float income[3]; This will create an array called income of type float that can hold three elements. Initialising...

Read More

Sorting - Bucket & Radix Sort

COMP202 Lectures

Bucket Sort Bucket sort is not based on comparisons but on using keys as indices of a bucket array. Initially all items of the input sequence $S$ are moved to appropriate buckets. An item with key $k$ is moved to bucket $B[k]$. Then move all items back into $S$ according...

Read More

Ant Structured Build

COMP285 Lectures

Standard Directory Names Directory Name Description src Source Files build/classes or bin Intermediate Output dist Distributeable Files All files apart from src are generated and can be deleted. Packages This is a method of grouping files together with their scope. The package is named using a reverse fully qualified name:...

Read More

Functions in C

COMP281 Lectures

A fragment of code that accepts zero of more argument values, produces a result value and has zero or more side effects. Arguments By default arguments are passed by value: int main (void) { putInFridge(eggs) return 0; } This means that if the variable changes in the function, the change...

Read More

Sorting - Counting Inversions & Quick Sort

COMP202 Lectures

Counting Inversions - Divide & Conquer The standard approach for counting inversions takes: \[\Omega(n^2)\] we can speed this up by using the following method. Divide the permutation into two fairly equal parts. Sort each sub-list and merge them into a single sorted list. Then count the inversions again. This is...

Read More

Control Structures, Functions & Libraries

COMP284 Lectures

Conditional Statements In addition to the standard curly brace notation we can also use the following notation: if (condition): statement endif This must be ended with the statement endif. It also supports conditional expressions: condition ? if_true_expr : if_false_expr Other conditional statements such as: Switch-Case If While & Do-While Break...

Read More

Ant Basics

COMP285 Lectures

To compile our source code with Ant we need the source file: public class Main { public static void main(String args[]) { for(int i=0;i<args.length;i++) { System.out.println(args[i]); } } } This should be placed in a folder called src to match the srcdir variable in the build file. and an Ant...

Read More

PHP - Arrays, Comparisons, Printing & NULL

COMP284 Lectures

Comparison Operators Type juggling affects the way that comparisons work in PHP, consequently there are some additional competitors: Expression Name Description expr1 == expr2 Equal TRUE if expr1 is equal to expr2 after type juggling. expr1 != expr2 Not Equal TRUE if expr1 is not equal to expr2 after type...

Read More

Loops in C

COMP281 Lectures

while This checks the statement before running the statements: while (<expression>) { <statements> } Be aware of the limits of the data-types you are using if you are including counters in your while loops. limits.h has information regarding maximum values. do while This checks the statement after running the statements:...

Read More