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.

Priority Scheduling

COMP124 Lectures

Shortest Remaining Time First A preemptive version of the shortest job first algorithm. Based on the remaining time rather than the burst time. CPU is allocated to the job that is closest to being completed. Can be preempted if there is a newer job in the ready queue that has...

Read More

Insertion Sort

COMP108 Lectures

Method Look up the elements one by one. Build up sorted list by inserting the element in the correct location. Example 34 10 64 51 32 21 Number shifted to right 34 10 64 51 32 21   10 34 64 51 32 21 34 10 34 64 51 32...

Read More

Selection Sort

COMP108 Lectures

Method Find minimum key from the input sequence. Delete it from input sequence. Append it to resulting sequence. Repeat until nothing is left in the original sequence. Example 34 10 64 51 32 21 To Swap 34 10 64 51 32 21 34, 10 10 34 64 51 32 21...

Read More

Scheduling Algorithms

COMP124 Lectures

FCFS Different Arrival Time What if the order of arrival changed to the following: gantt dateformat S axisformat %S P2: a, 0, 5s P3: b, after a, 1s P1: c, after b, 13s This would give the following average wait time: \[\frac{0+5+6}{3}=3.7\text{ms}\] This is significantly shorter than the original 10.3ms....

Read More

Bubble Sort - 2

COMP108 Lectures

This time we will be looking at bubble sort in a linked list. Linked List Pseudo Code if head = NIL then Empty list and STOP last = NIL curr = head while curr.next =/= last do begin while curr.next =/= last do begin if curr.data > curr.next.data then swapnode(curr,...

Read More

Bubble Sort - 1

COMP108 Lectures

Method Starting from the first element, swap adjacent items if they are not in ascending order. When last item is reached, the last item is the largest. Repeat the above steps for the remaining items to find the second largest item. When there is no change the list is sorted....

Read More

Process Scheduling

COMP124 Lectures

In any mutliprogramming situation, processes muyst be scheduled. The scheduler selects the next job from the ready queue: Determines which process gets the CPU, when and for how long. Also when processing should be interrupted. Various algorithms can be used Scheduling algorithms may be preemptive or non-preemptive Non-Preemptive Scheduling Once...

Read More

Polymorphism

COMP122 Lectures

Class Hierarchy = Type Hierarchy Every class defines a data type. Subclasses therefore define sub-types. Example Every circle is also a shape and thus can be assigned to a variable of type Shape. classDiagram Shape <|-- Circle class Shape{ +colour String +toString() String } class Circle{ +radius double +area() double...

Read More

Method Overriding

COMP122 Lectures

Overriding a Superclass Method A subclass inherits the public or protected attributes and methods in its superclass. It can override an inherited method (identified by its signature) by re-implementing an inherited method. Shapes Example classDiagram Shape <|-- Circle class Shape{ +colour String +toString() String } class Circle{ +radius double +area()...

Read More

Subclasses

COMP122 Lectures

Inheritance This is a mechanism of creating a new subclass based on an existing superclass, retaining a similar implementation. This allows the following two: Abstraction - It allows to express an “is-a” relationship. Every instance of the subclass is also and instance of the superclass. Code re-use - A subclass...

Read More