Given n terms, print the k most frequent terms in descending order of their frequency