By definition, all end ship segments (i.e. top, right, bottom and left) have another ship segment connected to them.
Example
In the example above, the left ship segment at (H,2) must have a neighboring ship segment at (H,3).
Even if you don't know the exact type of ship segment (in the example above, (H,3) might be a right or middle ship segment), you can finalize the square as a segment wildcard (a diamond-shaped segment).