COMP5000 Algorithms – Revision Notes

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play

1/29

encourage image

There are no tags or description

Looks like no tags are added yet.

30 Terms

1
New cards

Base (termination) condition

The stopping point of a recursive function that prevents infinite recursion.

2
New cards

Non-recursive work f(n)

The work a function does itself in each call, excluding recursive calls, written f(n).

3
New cards

Divide and conquer

Divide the problem into smaller parts, delegate each part to a recursive call, then combine the results.

4
New cards

Recurrence relation

The general form T(n) = r·T(n/c) + O(f(n)) describing the running time of a recursive algorithm, where r is the number of recursive calls and c is the shrink factor.

5
New cards

Levels when dividing by c

The number of levels in a recursion tree when dividing by c: L = log_c n.

6
New cards

Memoisation

Storing each computed result the first time it is calculated so it can be looked up later instead of recomputed, reducing naive Fibonacci to O(n).

7
New cards

Fast exponentiation

A technique computing x^n by calling power(x, n/2) once and squaring the result (multiplying by x if n is odd), giving O(log n) time.

8
New cards

Tower of Hanoi

A recursive puzzle moving n disks between pegs using a spare peg, with minimum moves equal to 2n−12^n - 1 and running time O(2n)O(2^n).

9
New cards

Mergesort

A divide-and-conquer sorting algorithm that splits an array in half, sorts each half recursively, and merges the sorted halves in O(n) time, giving O(nlog⁡n)O(n\log n) overall.

10
New cards

Quicksort

A sorting algorithm that picks a pivot, partitions elements into smaller and larger groups, and recursively sorts them; average O(nlog⁡n)O(n\log n), worst case O(n2)O(n^2).

11
New cards

Backtracking

A problem-solving method that builds a solution one choice at a time and undoes (backtracks) the last choice when a constraint is broken.

12
New cards

N Queens problem

The backtracking problem of placing N queens on an N×N board so that no two queens attack each other.

13
New cards

Subset Sum problem

The problem of deciding whether some subset of numbers adds up to a target value, solved by including or excluding each element, with worst case O(2n)O(2^n).

14
New cards

Proof by induction

A proof technique with a base case, an inductive hypothesis assuming correctness for smaller inputs, and an inductive step showing correctness for size n.

15
New cards

Decision problem

A problem with a Yes/No answer.

16
New cards

P (polynomial time)

The class of decision problems solvable in polynomial time by a deterministic algorithm.

17
New cards

NP (nondeterministic polynomial time)

The class of decision problems whose Yes answers can be verified in polynomial time.

18
New cards

CIRCUIT-SAT

The problem of deciding whether some input makes a Boolean circuit output 1; the standard first NP-complete problem.

19
New cards

Reduction

Transforming instances of problem A into instances of problem B in polynomial time, showing B is at least as hard as A.

20
New cards

Adjacency matrix

A graph representation using a V×V table of edges, with O(V²) space and quick edge lookup.

21
New cards

Adjacency list

A graph representation where each node stores a list of its neighbours, using O(V + E) space.

22
New cards

Depth-first search (DFS)

A graph traversal that explores as deep as possible first, using a stack or recursion.

23
New cards

Breadth-first search (BFS)

A graph traversal that explores level by level using a queue; it finds unweighted shortest paths.

24
New cards

Minimum spanning tree (MST)

A subset of edges connecting all nodes of a graph with minimum total weight and no cycles.

25
New cards

Prim's algorithm

An MST algorithm that repeatedly adds the cheapest edge joining the growing tree to a new node.

26
New cards

Kruskal's algorithm

An MST algorithm that sorts all edges by weight and adds the cheapest edge that does not create a cycle.

27
New cards

Dijkstra's algorithm

An algorithm finding shortest paths from one start node to all others in a graph with non-negative weights, using distances and a priority queue.

28
New cards

DAG (directed acyclic graph)

A directed graph with no cycles.

29
New cards

Halting problem

Result by Turing that no algorithm can decide, for every program and input, whether the program halts.

30
New cards

Babylonian method

An iterative algorithm for approximating square roots, used in lectures to discuss testing versus proving correctness.