Relationship between degree and number of relative extrema