advertisement

INSERT routine Input: A (partial) tableau T and a number a. Output: a is inserted in the tableau. The position of the last insert is returned. begin 1: j := 1;{We always start inserting in the first row} 2: repeat 3: if T has less than j rows then 4: Add a row containing a to T 5: return rec(r := j,c := 1); 6: elif a bigger then last element in row j of T then 7: Add a at the end of row j in T 8: return rec(r := j,c := |T [ j]|); 9: else 10: Let i be the index of the smallest element ≥ a in the j-th row {This is the position in the row where one could place a while satisfying the tableau properties!} 11: x := T [ j][i];{“Bump” out x to the next row} 12: T [ j][i] := a; 13: a := x; 14: j := j + 1; 15: fi; 16: until false end The RSK (ROBINSON , S CHENSTED , K NUTH) algorithm Input: A permutation in passive form [a1 , . . . , an ]. Output: Two tableaux S and T . begin 1: S := []; T := []; 2: for i ∈ [1, . . . , n] do 3: p := INSERT(S, ai ); 4: T [pr ][pc ] := i; 5: od; 6: return S and T ; end 1