I have sort of the same problem.
It started when the Imac went to sleep (with "put hard disk to sleep when possible" checked as a "energy saver" preference option") and I tried to wake it up... I would get the beach ball, and had to shut down using the power button.
For a while it would start right up again.
Now I get the flashing question mark when I try to start up.
So I was pulling the power plug, and waiting over 15 minutes before starting up with a pram zap, and then it would start.
But that also stopped working yesterday.
Now if I pull the plug and wait a few hours (sometimes overnight) and start up with a pram zap, it will usually start up.
I have turned off the "put hard drive to sleep when possible" option in Energy Saver preferences and it has been running for a few hours now.
I haven't shut down yet to see if it will restart, because I don't want to be without my computer till the new one gets here, and then I will decide if I should spend the money on a hard drive to see if that gets this IMac going - still a good machine, but now worth hundreds in repairs.
I had also reinitialized the drive and reinstalled the system software. That made no difference. Wiped it with the 7 times erase option - took 11 hours.
So, I am thinking it's a drive, but will probably try the memory trick also.
Glad to share