A nearly optimal sensor placement algorithm for boundary coverage