From cb7da851cd2392dd5da0c03f3c67918daf07cacd Mon Sep 17 00:00:00 2001
From: AvinashDwivedi <avinashdwivedig@gmail.com>
Date: Sat, 22 Oct 2022 04:53:29 +0530
Subject: [PATCH] Matrix search code added for a sorted matrix

---
 Sorting_Searching/matrix_in_search.py | 29 +++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 Sorting_Searching/matrix_in_search.py

diff --git a/Sorting_Searching/matrix_in_search.py b/Sorting_Searching/matrix_in_search.py
new file mode 100644
index 0000000..feffb80
--- /dev/null
+++ b/Sorting_Searching/matrix_in_search.py
@@ -0,0 +1,29 @@
+def search(mat, n, x):
+ 
+    i = 0
+    j = n - 1
+    while (i < n and j >= 0):
+ 
+        if (mat[i][j] == x):
+ 
+            print("Element found at row: ", i, ", column: ", j)
+            return 1
+ 
+        if (mat[i][j] > x):
+            j -= 1
+ 
+        # if mat[i][j] < x
+        else:
+            i += 1
+ 
+    print("Element not found")
+    return 0
+ 
+if __name__ == "__main__":
+    mat = [[10, 20, 30, 40],
+           [15, 25, 35, 45],
+           [27, 29, 37, 48],
+           [32, 33, 39, 50]]
+ 
+    # Function call
+    search(mat, 4, 29)
\ No newline at end of file