I looked up the spelling of ‘smart aleck’ recently, saw it ended with a ‘k’, wondered where that came from. Incidentally, both aleck and alec are accepted. Google found this:
According to G.L. Cohen, author of Studies in Slang Part 1 (1985), the phrase smart alec(k) arose from the exploits of one Alec Hoag. A celebrated pimp, thief, and confidence man operating out of New York City in the 1840’s, Mr. Hoag, along with his wife Melinda and an accomplice known as "French Jack," operated a con called the "panel game," a method by which prostitutes and their pimps robbed foolish customers.