Characterizations of Noetherian and hereditary rings