Should one join a prayer for a deceased person after it has started, how does he make up for the part he missed?

The prayer for a deceased person, i.e. Janazah prayer, is a congregational prayer consisting of four Takbeers, which is signaled by the Imam saying Allahu Akbar.
After the first one we read the opening Surah of the Qur’an, Al-Fatihah;
After the second we read the second half of Tashahhud;
after the third we pray to God to bestow His grace on the deceased and forgive him or her for their sins; and
after the fourth we say a short prayer for all Muslims in all generations.

If one arrives late and finds that the Janazah prayer has already started without knowing which part it has reached, he joins the imam, starting his prayer normally. He is better advised to finish his prayer with the imam without completing any missed part.

The Prophet, peace be upon him, was asked by his wife, Ayesha: “Messenger of God, I sometimes offer the Janazah prayer but cannot hear some Takbeers.” He said to her: “What you hear, follow the imam; and what you miss, you need not compensate for it.” This is the standard view. However, some scholars prefer that a person who has missed any part of the prayer for a deceased person should complete it after the imam has finished. Whichever view one follows is acceptable, although the first one, which means to finish with the imam, is perhaps weightier.