src/com/michaelho/DivideAndConquer/DC4.java
/**
         * Naive approach to multiply 2 polynomials.
         * Runtime: O(N^2)
         *
         * @param A The first polynomial represented in integer array.
         * @param B The second polynomial represented in integer array.
         *
         * @return the multiplication result as an integer array.
         * */
Naive approach to multiply 2 polynomials.

@param A The first polynomial represented in integer array.
@param B The second polynomial represented in integer array.

@return the multiplication result as an integer array.
Naive approach to multiply 2 polynomials . @param A The first polynomial represented in integer array . @param B The second polynomial represented in integer array . @return the multiplication result as an integer array .
int[] multiplication(int[] A, int[] B) {
            int[] output = new int[A.length + B.length - 1];
            for (int i = 0; i < output.length; i++) {
                output[i] = 0;
            }
            for (int i = 0; i < A.length; i++) {
                for (int j = 0; j < B.length; j++) {
                    output[i+j] += A[i]*B[j];
                }
            }
            return output;
        }
int [ ] multiplication ( int [ ] A , int [ ] B ) { int [ ] output = new int [ A . length + B . length - 1 ] ; for ( int i = 0 ; i < output . length ; i ++ ) { output [ i ] = 0 ; } for ( int i = 0 ; i < A . length ; i ++ ) { for ( int j = 0 ; j < B . length ; j ++ ) { output [ i + j ] += A [ i ] * B [ j ] ; } } return output ; }
Naive approach to multiply 2 polynomials.
Naive approach to multiply 2 polynomials .