The algorithmic solution to this was asked as a question in GATE 1996
https://gateoverflow.in/2766/gate1996-14
smsubham
$best$ $solution$
@Sachin Mittal 1 sir to which topic of Algorithm can I relate this question to ?
@Arjun sir with m rows and n column.
time complexity to delete smallest element is O(m+n)
time complexity to delete largest element is O(m+n)
time complexity to delete element is O(m+n) ryt?
Answer: 6
Shift $2,4,6,18,25, \infty$ in a zig-zag manner.
I don't think we need to count ∞ shift. we just have to fill the unfilled entries.
After removing 1
NULL moves right:
(Note: NULL cannot move down because it will contradict the given question conditions. Hence, we have to move right.)
NULL moves down:
Now in question given that " Unfilled entries are filled with infinite
Therefore:
We will not bring NULL to the bottom right because question is asked to find the minimum.
Since total 5 movements of NULL is involved:
The answer will be 5
64.3k questions
77.9k answers
244k comments
80.0k users