EXTRACT MIN algorithm for Young tableau This are two sections from a task I got.


  The Young tableau is defined as a matrix of m rows on n columns so that
  the bars in each row are sorted in ascending order Left to right and
  the elements in each column are sorted in ascending order from top to
  bottom. Some of the elements in the Young tableau may be $\infty$ we
  will refer to these elements as non-existent elements . Therefore, the
  Young tableau can be used to hold finite numbers.
  
  
  Write an algorithm for EXTRACT-MIN on a non-empty Young tableau of m at n in time running  $O(n+m)$
  Show how to insert a new element into a non-complete Young tableau v at the size of m at n in time running  $O(m+n)$   
  


That's what I tried:

When I remove the element at the $(1,1)$ I need to move every element in the table 1 step left (and if the col is 1 so move one row up and put it on the last col) so I can solve it on $O(n*m)$. I think that $O(m+n)$ actually measn $O(max(m,n))$

Regarding the second clause I was thinking to compare the element to insert with the element in the first col in every row until until we get to bigger one and then and then check on this row where to insert it. But again let's say that I want to insert element which will be the min on the new table, so I need to push all the elements one stop left and it takes $O(m*n)$
Hint: For EXTRACT-MIN, instead of thinking in terms of shifting rows/columns, try to replace the element at $(1,1)$ by $+\infty$. Now you just want to swap $+\infty$ with one of his neighbour until you get the invariant of a Young tableau. How can you decide where to move it?