Question: I'm having problems creating an algorithm that does the following, in JAVA: Find whether an int is in an ordered 2D array, sorted by the
I'm having problems creating an algorithm that does the following, in JAVA:
Find whether an int is in an ordered 2D array, sorted by the following rules:
a. The rows are sorted increasing from left to right.
b. The columns are sorted increasing from top to bottom.
c. The algorithm must run, at worst-case, in O(N) time.
The sample matrix we're given is this -
Honestly lost on this implementation.
int a; a new int[][] t new int 2, 14, 26, 37, 43, 51 t, new int 1 t 4, 16 28 38, 44 54, t, new int 6, 18 30 39, 45, 57 t, new intr 1 t 8, 20, 32, 40, 46, 60 t, new int 10, 22 34, 41, 47 63, t, new int f 12, 24, 36, 42, 48, 66 tStep by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
