There are cases of MPs being elected posthumously; Edward Legge (1710-47) was elected unopposed as MP for Portsmouth on 15 December 1747, four days before news arrived that he had died 87 days previously in the West Indies.
The shortest non-posthumous service was that of Alfred Dobbs, who was declared elected MP for Smethwick on 26 July 1945 and was killed the following day in a car accident on the way to take his seat [REF].