With help from readers, I managed to solve the problem of spam flooding my mailbox that started happening at the same time I switched to the Mavericks operating system on my Mac.
Following the specific suggestions of commenters fwtbc and Anthony Burber on how to diagnose it, I found that the problem was that for some reason, Gmail was detecting the spam and correctly putting it in the spam folder but then the entire spam folder was being downloaded to my Mail client into the Junk folder, mixing it up with the few merely suspect mail that normally goes into that folder. By adjusting the settings on my Gmail account, I was able to prevent that from happening.
What is interesting is that I had to make the change in the Gmail settings rather than in my Mail preferences, which is where I thought the problem would be, since it was the switch to Mavericks that triggered the issue. So did my upgrade to Mavericks somehow change the settings on the Gmail account? That seems strange and unlikely. Perhaps the earlier Mail client had settings that automatically steered the Gmail spam away from the Junk mail folder. Or maybe for some reason Gmail changed my settings at around the same time. One can never rule out such coincidences.
Whatever the reason, the problem is now gone so thanks to everyone who helped out.