Table construction algorithm.

Table construction algorithm.