A linear time algorithm for finding a K5-model