diff --git a/algorithms/searches/2D_array_search.py b/algorithms/searches/2D_array_search.py new file mode 100644 index 0000000..eda747d --- /dev/null +++ b/algorithms/searches/2D_array_search.py @@ -0,0 +1,23 @@ + +#it's a searching algorithm for sorted 2D matrix and complexity O(n+m) where n is number of rows and m is number of columns +n,m= map(int,input().split()) #taking row and column input +arr = [[int(input()) for x in range (m)] for y in range(n)] #entering elements into the matrix + +k = int(input("enter the search element: ")) +flag = False + +i,j = 0, m-1 +#main algorithm +while((i>=0) and (j>=0) and (i k): + j-=1 + else: + i+=1 + +if(flag): + print("element found") +else: + print("element not found") pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy