COP5025

Representative Problems

We will look at solutions to several problems across several language paradigms in order to relate the paradigms.

If A is an m-by-n matrix and B is an n-by-p matrix, then their product is an m-by-p matrix denoted by AB (or sometimes A · B). The product is given by

(AB)_{ij} = \sum_{r=1}^n a_{ir}b_{rj} = a_{i1}b_{1j} + a_{i2}b_{2j} + \cdots + a_{in}b_{nj}.
Every one of the  m x p product elements is at some location  [i][j] AB.
Its value is the sum of the products: i.e.  for (r=0,sum=0;r<n;r++) sum+=A[i][r]*B[r][i];

A Java Solution

Add two numbers (of any length) where each is presented as a list of digits: addend1 & addend2.

The algorithm is that of your school days:   sum[i] = addend1[i]+addend2[i]+carry[i]  , where the first carry is zero

A Java Solution