Both Shakespeare's lead character in the play Macbeth and Alfred, Lord Tennyson's lead character in the poem "Ulysses" have heroic and villainous sides to them.
At the beginning of Macbeth, Macbeth has many heroic qualities: he is brave, he is noble (in station and deeds), and he is loyal to his kinsman Duncan, having just fought, very well in fact, to defend him. The play can certainly be read with Macbeth as the tragic hero, his misdeeds and the loss of these excellent heroic qualities the result of a sketchy prophecy and crazy-ambitious wife. After all, Macbeth's reaction to the three witches shows that he is perhaps not as in control as he could be. When they meet the witches and Macbeth hears the prophecy, Banquo describes him as "rapt," as if he is in a trance. After Lady Macbeth urges him to kill Duncan, Macbeth says in a soliloquy that he sees a "dagger of the mind" before him, leading him on to the deed. So the argument could be made that he is a hero undone by a heroic flaw.
However, many readers disagree with that casting and see Macbeth as an over-ambitious villain who allowed himself to be tempted into giving in to his basest nature. It's certainly not hard to find evidence of this. Even after Macbeth has killed Duncan and driven his heirs out of Scotland, even after Macbeth himself is king, he is still afraid. He kills Banquo and tries to kill his son. He has all of Macduff's family killed, including the children, justifying it by saying:
"For mine own good
All causes shall give way. I am in blood
Stepp'd in so far that, should I wade no more,
Returning were as tedious as go o'er" (3.4.167-170).
I've already killed so many people a few more won't hurt is just about the most villainous excuse in the book. Whoever Macbeth was at the beginning of the play, he is showing a vastly different side of himself at this point.
Tennyson's Ulysses was originally hailed as a hero, based as he is off of the Greek hero of the Trojan War and mythic star of the Odyssey. That such a figure would go off on adventures and take risks is taken for granted in such readings; that's part of his charm, after all. He is the traditional hero who goes off in search of a noble quest and great deeds. Even though he and his men are old, they are:
"One equal temper of heroic hearts,
Made weak by time and fate, but strong in will
To strive, to seek, to find, and not to yield" (ln 68-70)
This human need to continue to search and strive for more is a common one in literature, and many see it as noble. Still, there are other aspects of the poem that show Ulysses as more selfish than heroic. He is proposing giving up his duties to his family and people—he is, after all, king. His call for a flight from responsibility includes such unflattering lines as:
"Match'd with an aged wife, I mete and dole
Unequal laws unto a savage race,
That hoard, and sleep, and feed, and know not me" (ln 3-5).
Furthermore, his call for his comrades to join him on his adventure sounds eerily like a call to death, a glorious suicide that will give Ulysses the ego trip he isn't getting at home. After all, his purpose is:
"To sail beyond the sunset, and the baths
Of all the western stars, until I die" (ln 60-61).
Clearly, both Macbeth and Ulysses are complex characters who refuse to be forced into a single, simplistic label and instead present the varied, complex human experience.