Frage

Consider an operation like binary multiplication between one array with size (1*4) and matrix with size (4*8), as you know we obtain as the output an array of size (1*8).

Is the complexity of this operation O(1) ?

War es hilfreich?

Lösung

The sizes of the matrices are specified in your question.

Since the size of the problem never changes the complexity will be O(1).

The complexity would be O(n) when you would need to treat your input data exactly once.

For example, multiplying every number in an array of length n by 2 is of complexity O(n).

Now as far as your problem is concerned, if the size of your matrices was variable then the run time would be O(n^3), if we assume a naive implementation.

See Wikipedia for more details.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top