OptimalHypothesisSelectionin(Almost) LinearTime