Skip to content

Commit cde9409

Browse files
Refactor strassen function examples for clarity
Updated examples in the strassen function to improve readability and clarity.
1 parent dda49c5 commit cde9409

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

divide_and_conquer/strassen_matrix_multiplication.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,15 @@ def strassen(matrix1: list, matrix2: list) -> list:
119119
>>> strassen([[2,1,3],[3,4,6],[1,4,2],[7,6,7]], [[4,2,3,4],[2,1,1,1],[8,6,4,2]])
120120
[[34, 23, 19, 15], [68, 46, 37, 28], [28, 18, 15, 12], [96, 62, 55, 48]]
121121
122-
>>> strassen([[3,7,5,6,9],[1,5,3,7,8],[1,4,4,5,7]], [[2,4],[5,2],[1,7],[5,5],[7,8]])
123-
[[139, 163], [121, 134], [100, 121]]
122+
>>> strassen(
123+
... [[3,7,5,6,9],[1,5,3,7,8],[1,4,4,5,7]],
124+
... [[2,4],[5,2],[1,7],[5,5],[7,8]]
125+
... )
126+
124127
125128
Complexity Notes:
126129
- Classical matrix multiplication: O(n^3).
127-
- Strassens algorithm: O(n^(log2(7))) ≈ O(n^2.81).
130+
- Strassen's algorithm: O(n^(log2(7))) ≈ O(n^2.81).
128131
- Strassen reduces the number of multiplications from 8 to 7 per recursion,
129132
trading them for additional additions/subtractions.
130133
"""

0 commit comments

Comments
 (0)