From 5795355e797fa1229fd55ec3e325d75e8d297383 Mon Sep 17 00:00:00 2001 From: Shuvojit Samanta <142198651+shuvojitss@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:26:46 +0530 Subject: [PATCH 1/6] Create Strassen's_Matrix_Multiplication.py --- .../Strassen's_Matrix_Multiplication.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py diff --git a/Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py b/Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py new file mode 100644 index 0000000000..c57a523d1c --- /dev/null +++ b/Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py @@ -0,0 +1,51 @@ +# Python code to perform 2x2 matrix multiplication using Strassen's method +import numpy as np + +def main(): + x = np.zeros((2, 2), dtype=int) + y = np.zeros((2, 2), dtype=int) + z = np.zeros((2, 2), dtype=int) + + print("Enter the elements of the first matrix (2x2):") + for i in range(2): + for j in range(2): + x[i][j] = int(input()) + + print("Enter the elements of the second matrix (2x2):") + for i in range(2): + for j in range(2): + y[i][j] = int(input()) + + print("\nThe first matrix is:") + for i in range(2): + for j in range(2): + print(f"{x[i][j]}\t", end="") + print() + + print("\nThe second matrix is:") + for i in range(2): + for j in range(2): + print(f"{y[i][j]}\t", end="") + print() + + m1 = (x[0][0] + x[1][1]) * (y[0][0] + y[1][1]) + m2 = (x[1][0] + x[1][1]) * y[0][0] + m3 = x[0][0] * (y[0][1] - y[1][1]) + m4 = x[1][1] * (y[1][0] - y[0][0]) + m5 = (x[0][0] + x[0][1]) * y[1][1] + m6 = (x[1][0] - x[0][0]) * (y[0][0] + y[0][1]) + m7 = (x[0][1] - x[1][1]) * (y[1][0] + y[1][1]) + + z[0][0] = m1 + m4 - m5 + m7 + z[0][1] = m3 + m5 + z[1][0] = m2 + m4 + z[1][1] = m1 - m2 + m3 + m6 + + print("\nResultant matrix:") + for i in range(2): + for j in range(2): + print(f"{z[i][j]}\t", end="") + print() + +if __name__ == "__main__": + main() From 5e6325cbcffcc9efdce82a4644eed55dcb4c1adf Mon Sep 17 00:00:00 2001 From: shuvojitss Date: Wed, 30 Oct 2024 12:57:35 +0000 Subject: [PATCH 2/6] updating Project-Structure.md --- Project-Structure.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Project-Structure.md b/Project-Structure.md index ceaf368a33..0bd124ce07 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -44,6 +44,7 @@ * Branch And Bound * [8 Puzzle](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Branch_and_Bound/8_puzzle.py) * Divide And Conquer + * [Strassen'S Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) * [Binary Search](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/binary_search.py) * [Merge Sort](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/merge_sort.py) * [Min Max](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/min_max.py) From 818f202b2264c1a10416e753e23944ec346a6029 Mon Sep 17 00:00:00 2001 From: Shuvojit Samanta <142198651+shuvojitss@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:43:54 +0530 Subject: [PATCH 3/6] Update Project-Structure.md --- Project-Structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project-Structure.md b/Project-Structure.md index 0bd124ce07..34fddf6f5d 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -44,7 +44,7 @@ * Branch And Bound * [8 Puzzle](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Branch_and_Bound/8_puzzle.py) * Divide And Conquer - * [Strassen'S Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) + * [Strassen's Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) * [Binary Search](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/binary_search.py) * [Merge Sort](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/merge_sort.py) * [Min Max](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/min_max.py) From 2993940a9982d66af445d591a1bd444de7c4b905 Mon Sep 17 00:00:00 2001 From: shuvojitss Date: Wed, 30 Oct 2024 13:14:44 +0000 Subject: [PATCH 4/6] updating Project-Structure.md --- Project-Structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project-Structure.md b/Project-Structure.md index 34fddf6f5d..0bd124ce07 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -44,7 +44,7 @@ * Branch And Bound * [8 Puzzle](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Branch_and_Bound/8_puzzle.py) * Divide And Conquer - * [Strassen's Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) + * [Strassen'S Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) * [Binary Search](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/binary_search.py) * [Merge Sort](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/merge_sort.py) * [Min Max](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/min_max.py) From dbe24d9a802033ccb36910a826ea826134b39cfc Mon Sep 17 00:00:00 2001 From: Shuvojit Samanta <142198651+shuvojitss@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:51:53 +0530 Subject: [PATCH 5/6] Update Project-Structure.md --- Project-Structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project-Structure.md b/Project-Structure.md index 0bd124ce07..34fddf6f5d 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -44,7 +44,7 @@ * Branch And Bound * [8 Puzzle](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Branch_and_Bound/8_puzzle.py) * Divide And Conquer - * [Strassen'S Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) + * [Strassen's Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) * [Binary Search](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/binary_search.py) * [Merge Sort](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/merge_sort.py) * [Min Max](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/min_max.py) From 0fd3b89282845627eb94c7da4de711b20bcb2e54 Mon Sep 17 00:00:00 2001 From: shuvojitss Date: Wed, 30 Oct 2024 13:22:51 +0000 Subject: [PATCH 6/6] updating Project-Structure.md --- Project-Structure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project-Structure.md b/Project-Structure.md index 34fddf6f5d..0bd124ce07 100644 --- a/Project-Structure.md +++ b/Project-Structure.md @@ -44,7 +44,7 @@ * Branch And Bound * [8 Puzzle](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Branch_and_Bound/8_puzzle.py) * Divide And Conquer - * [Strassen's Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) + * [Strassen'S Matrix Multiplication](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/Strassen's_Matrix_Multiplication.py) * [Binary Search](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/binary_search.py) * [Merge Sort](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/merge_sort.py) * [Min Max](Algorithms_and_Data_Structures/Design_and_Analysis_of_Algorithms/Divide_and_Conquer/min_max.py)