Although sometimes classified as interjections, these words do not express emotion or act as calls for attention; they are not adverbs because they do not qualify any verb, adjective, or adverb. They are sometimes classified as a part of speech in their own right: sentence words or word sentences.
This is the position of Otto Jespersen, who states that "'Yes' and 'No' are to all intents and purposes sentences just as much as the most delicately balanced sentences ever uttered by Demosthenes or penned by Samuel Johnson."