Firstly I would like to mention that i have a 3 gb ram.
I am working on an algorithm that is exponential in time on the nodes so for it I have in the code
It won't work. Looping over an iterator won't work either. You see, if the code in the for-loop takes 1 microsecond to run, it will take 2.587×10^34 years to run completely. (See http://www.wolframalpha.com/input/?i=40%21+microseconds+in+years)