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.

Lecture 6-2

COMP105 Lectures

List Comprehensions List ranges can produce simple arithmetic sequences but list comprehensions can produce more complex lists: > [x*x | x <- [1..10]] > [1,4,9,16,25,36,49,64,81,100] By using this you can apply a function to a list and put the result into a list. Predicates Predicates also add evaluations into the...

Read More

Lecture 6-1

COMP105 Lectures

List Ranges A list range lets us write a long list in a compact way: > [1..10] > [1,2,3,4,5,6,7,8,9,10] If the start is bigger than the end then you will get an empty list. This means you can’t count down in a list in this way. Using .. also works...

Read More

Lecture 5-2

COMP105 Lectures

Lists A list contains any number of items that all have the same type. [1, 2, 3, 4, 5] ['a', 'b', 'c', 'd', 'e'] Lists are built with [] as opposed to tuples which are built with(). A list can have any number of elements including 0. [] [1] [1,...

Read More

Lecture 5-1

COMP105 Lectures

Tuples A tuples allows us to bind two or more values together: (1,2) ("A", "few", "words") (6, "six") Tuples can have any size but must be at least 2. The size should be thought of as being fixed as it is not easy to change the length of a tuple....

Read More

Properties of Searches

COMP111 Lectures

For all algorithms there are certain properties that they can be evaluated against: Completeness Does the algorithm always find a solution if one exists? This is true for BFS but not for DFS as cycles can stop depth first if there is a loop. Optimality Does the algorithm always find...

Read More

Depth First Search

COMP111 Lectures

Depth first always selects the longest path from the frontier as opposed to the shortest path. From the perspective of the frontier you are expanding the path that was most recently added as opposed to the oldest path in the frontier. Change to Pseudo-code 7: select and remove from frontier...

Read More

Breadth First Search

COMP111 Lectures

Select and expand start state to give a tree of depth 1. Select and expand all paths that resulted from previous step to give a tree of depth 2. and so on. In general select adn expand all paths of depth $n$ before depth $n + 1$ Maze example First...

Read More

Tutorial 1

COMP111 Tutorials

Covering the tutorial sheets from week 1. The tutorial leader’s email is F.Alves@liverpool.ac.uk. The leader chose to cover one of the options which was football. Performance Measure Games won, goals scored. Environment Football pitch, the players, the ball. Actuators Legs, head. Sensors Visual, hearing, pressure. Classification Partially observable environment as...

Read More

Catch-up Session 2

COMP109 Catch-up+Sessions

Methods of Proof Counter Example Method Prove that a statement is false by use of a counter-statement. Universal Proof Applies to all integers e.g. odd if $a=2k+1$ Example \((a+b)^2=a^2+b^2\) Holds for: Some integers All integers No integers The answer is that it holds for some integers as when $a=0,\ b=0$....

Read More