An m × n Young tableau is an m × n matrix such that the entries of each row are
in sorted order from left to right and the entries of each column are in sorted order
from top to bottom. Some of the entries of a Young tableau may be 1, which we
treat as nonexistent elements. Thus, a Young tableau can be used to hold <= mn
finite numbers.
a. Draw a 4*4 Young tableau containing the elements {9; 16; 3; 2; 4; 8; 5; 14; 12}.
b. Argue that an m * n Young tableau Y is empty if Y [1, 1] = INT_MAX. Argue that Y
is full (contains m*n elements) if Y[m,n] < MAX.
c. Give an algorithm to implement EXTRACT-MIN on a nonempty m * n Young
tableau that runs in O(m * n) time. Your algorithm should use a recursive
subroutine that solves an m ( n problem by recursively solving either
an .(m - 1)* n or an m * (n - 1) subproblem. (Hint: Think about MAX-HEAPIFY.)
Define T.p/, where p D m C n, to be the maximum running time
of EXTRACT-MIN on any m ( n Young tableau. Give and solve a recurrence
for T(p) that yields the O(m + n) time bound.
d. Show how to insert a new element into a nonfull m * n Young tableau in
O(m * n) time.
e. Using no other sorting method as a subroutine, show how to use an n*n Young
tableau to sort n2 numbers in O.n3/ time.
f. Give an O(m * n)-time algorithm to determine whether a given number is
stored in a given m * n Young tableau.
Solution:
a. Ignore
b. Ignore
c. extract min
Analyse:
The left-top element of the table is the minimum. We have to remove this element and adjust the table
Solution:
1. Find a element A[i,j] that is on the bottom border or the right boder of the valid part of the matrix
2. put the element A[i,j] to A[1,1], marked by A[ k, l]
3. Get A[k, l] with A[k+1, l] and A[k, l+1], find the minimum of the three. (Take care of the table bottom and right bound.)
4. if A[k,l] is the minimum, go to end.
5. replace A[k, l] with the minimum, and update the index of i,j.
6. repeat 3, 4 and 5.
d. insert an element
Analyse:
To insert the element, at the start I don't want to change the current table too much, because it's so regulated.
Solution:
1. Put the element at a corner that's MAX.
2. repeat step c.3 c.4 c.5. with exception that the element to compare is A[k,l], A[k-1, l], A[k, l-]. (Take care of the tabletop and left bound.)
e. sort using the table
Analyse:
Each time we have disciplined Young tableaus, we have min at the left-top cornor.
Solution
1. Build a Young-Tablify procedure. which given a set of data, first put the data into a table sequentially, and then adjust each element from the right-bottom to left-top direction. Just as the building of a heap.
2. Extract-Min repeatedly until no element is left.
f. find a target
Analyse:
T :the target to look for.
1. We have utilize the information of element order in the table.
2. A[i,j] < any of {A[x,y] | x > i, y > j};
Solution:
1. Loop through the left border of the table, find the last element that's not larger than T
2. Go right. until we reached at the last element not larger than T.
3. Go up a row.
4. repeat step 2 and step 3.
Return condition: In the process of loop if we encounter the element, return true. If we can't go ahead because we have been at the border, return false.
From: http://blog.csdn.net/cheetach119/article/details/9357731