Depth of far clipping plane (usually 1) will also suffice
WritePixel(int x, int y, float z, colour)
if ( z < zbuf[x][y] ) then
zbuf[x][y] = z;
frambuffer[x][y] = colour;
end
Z-buffer is the algorithm of choice for hardware implementation
But memory is cheap!