I'm trying to implement the Robinson-Schensted Algorithm:

Quote

Given a Young tableau T, to row insert x into T,

* Set R equal to the first row of T

* While R contains an element greater than x, do

* Let y be the smallest element of R greater than x.

* Replace y by x in R.

* Set x = y and set R equal to the next row down.

* Place x at the end of the row R and stop.

* Set R equal to the first row of T

* While R contains an element greater than x, do

* Let y be the smallest element of R greater than x.

* Replace y by x in R.

* Set x = y and set R equal to the next row down.

* Place x at the end of the row R and stop.

http://en.wikipedia....nsted_algorithm

I've used a 2D Java Array, and am trying to traverse it to fill in a new element in the correct position according to the algorithm.

Here is some code I've come up with:

int y = currentElement; for (int i = 0; i < rowCount; i++) { int z = tableaux[rowCount][i]; if (z < y) { tableaux[rowCount][i+1] = y; } else { tableaux[rowCount][i] = y; } }

Am I on the right lines? It's really confusing me :S

It doesnt seem to be working, what's wrong?

Sorry if the code is really bad, im still a beginner

Thanks!