A Linear Time Algorithm for Computing Longest Paths