Skip to content
Official PYQ · 2015

GATE CS 2015 Set 2 Q31 — Arrays, Stacks and Queues

Explain with AI
A Young tableau is a 2D2D array of integers increasing from left to right and from top to bottom. Any unfilled entries are marked with ∞\infty, and hence there cannot be any entry to the right of, or below a ∞\infty. The following Young tableau consists of unique entries.
12514346231012182531∞∞∞\begin{array}{|l|l|l|l|}\hline \textbf{1} & \text{2}& \text{5} & \text{14} \\ \hline \text{3} & \text{4} & \text{6} & \text{23} \\ \hline \text{10} & \text{12} & \text{18} & \text{25} \\ \hline \text{31} & \text{$\infty$} & \text{$\infty$} & \text{$\infty$} \\ \hline \end{array}
When an element is removed from a Young tableau, other elements should be moved into its place so that the resulting table is still a Young tableau (unfilled entries may be filled with a ∞\infty). The minimum number of entries (other than 11) to be shifted, to remove 11 from the given Young tableau is _____.
View worked solution

Answer: 5

To remove the minimum element (which is 11 at cell (0,0)(0,0)) from a Young tableau while preserving its properties, we perform a procedure similar to heapify-down:

  1. Replace the element to be deleted with ∞\infty.
  2. Compare the current cell with its right neighbor and its bottom neighbor.
  3. Swap (or shift) the smaller of the two neighbors into the current cell.
  4. Repeat this process for the empty cell until both neighbors are ∞\infty or out of bounds.

Let's trace the step-by-step shifts starting from (0,0)(0,0) after removing 11:

  • Step 1: At (0,0)(0,0), neighbors are 22 (right) and 33 (bottom). Since 2<32 < 3, we shift 22 to (0,0)(0,0). The empty cell is now at (0,1)(0,1).
  • Step 2: At (0,1)(0,1), neighbors are 55 (right) and 44 (bottom). Since 4<54 < 5, we shift 44 to (0,1)(0,1). The empty cell is now at (1,1)(1,1).
  • Step 3: At (1,1)(1,1), neighbors are 66 (right) and 1212 (bottom). Since 6<126 < 12, we shift 66 to (1,1)(1,1). The empty cell is now at (1,2)(1,2).
  • Step 4: At (1,2)(1,2), neighbors are 2323 (right) and 1818 (bottom). Since 18<2318 < 23, we shift 1818 to (1,2)(1,2). The empty cell is now at (2,2)(2,2).
  • Step 5: At (2,2)(2,2), neighbors are 2525 (right) and ∞\infty (bottom). Since 25<∞25 < \infty, we shift 2525 to (2,2)(2,2). The empty cell is now at (2,3)(2,3).
  • At (2,3)(2,3), both neighbors are ∞\infty (or out of bounds), so the process terminates by placing ∞\infty at (2,3)(2,3).

The elements shifted are 2,4,6,18,2, 4, 6, 18, and 2525. Thus, the minimum number of entries shifted is 55.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Arrays, Stacks and Queues questions