📎

Problems in this course

Matrix-vector multiplication

Input:

(n×m)(n \times m) matrix AA

mm element vector v⃗\vec v

Output:

u⃗=A⋅v⃗\vec u = A \cdot \vec v

u[i]=∑A[i,j]⋅v[j]u[i] = \sum A [i, j]\cdot v[j]

Matrix-matrix multiplication

Input:

(n×l)(n \times l) matrix AA

(l×m)(l \times m) matrix BB

Output:

(n×m)(n \times m) matrix CC

C=A⋅BC = A \cdot B

C[i,j]=∑A[i,k]⋅B[k,j]C[i, j]=\sum A[i, k] \cdot B[k, j]

Solving linear equation

Input:

matrix AA

vector b⃗\vec b

Output:

AA must be preprocessed, such that solutions can be easily found for any b⃗\vec b .

An x⃗\vec x such that

b⃗=A⋅x⃗\vec b = A \cdot \vec x

Stencil computation

Input:

(n×m)(n \times m) matrix AA

Output:

Updated version of AA such that a convergence criteria is met

Matrix borders must be handled in a suitable way

iterate {
for all (i, j) {
A[i,j] <- (A[i-1,j] + A[i+1,j] + A[i,j-1] + A[i,j+1])/4
}
} until (convergence)

Merge and sort two arrays

Input:

Array of size nn

Array of size mm

Output:

Merged array of size n+mn+m

Get all prefix-sums

Input:

Array of size nn with elements of type SS

Associative operation ++

Output:

B[i]=∑0≤j<iA[j]B[i]= \sum_{0 \leq j < i} A[j]

Example

A:1,2,3,4,…A: 1,2,3,4,\dots

B:x,1,3,6,10,15,…B: x, 1,3,6,10,15, \dots

Sort array

Sorting a sequence of objects such as (real numbers, integers, objects with an order relation) in an array.

Graph search

Input:

G=(V,E)G = (V,E)

with a start s∈Vs \in V

Output:

computed DFS or BFS traversal of GG from ss

Graph analysis:

  1. Given undirected GG , find all the connected components CCCC
  1. Given directed GG , find all strongly connected components SCCSCC

Graph analytics

Input:

G=(V,E)G = (V,E)

Output:

computed property, ie. “betweenness centrality” for all VV