Java Reference
In-Depth Information
procedure C
ompress
()
for i =
1 to N × M do
V . entry [ i ]
14
de f ault
foreach row ∈{
1
,
2
,..., N }
do
15
R [ row ]
F
ind
S
hift
( row )
for j =
1 to M do
if T [ row , j ]
de f ault
then
place R [ row ]
+ j
V . entry [ place ]
T [ row , j ]
V . fromrow [ place ]
row
call T
runc
( V )
16
end
function F
ind
S
hift
( row ) returns Integer
return N × M M
( row , shi f t )
min
shi f t =− M +
F
its
1
end
function F
its
( row , shi f t ) returns Boolean
for j =
1 to M do
if T [ row , j ]
de f ault and not R
oom
I
n
V( shi f t + j )
17
then return ( false )
return ( true )
end
function R
oom
I
n
V( where ) returns Boolean
if where
1
then
if V . entry [ where ]
= de f ault
then return ( true )
return ( false )
end
procedure T
( V )
for i = N × M downto 1 do
if V . entry [ i ]
runc
de f ault
then
/
Retain V [1
... i ]
/
return ()
end
Figure 5.23: Compression algorithm.
 
Search WWH ::




Custom Search