6-3 Young tableaus

6-3 Young tableaus
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





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值