A midshipman is a sort of apprentice officer. It's used by USns to refer to a student at the US Naval Academy, but in the old days it was more On the Job Training (OJT). King's Ransom is just a very large sum of money. It's a metaphorical usage, the amount of money it would take to pay someone for the release of a king taken hostage.