Quote:
Originally Posted by inihility
This is actaully a really simple recursion (for-loop), but I'm having some trouble optimizing it so that it would run faster.
I don't understand why this is recursive
Quote:
Originally Posted by inihility
- for (int i = 0; i < 50; i++)
-
{
-
a[i] = getNumber(i);
-
}
Right now it takes around 40-50 seconds to run.
50 iterations shouldn't take very long. If you took out the "getNumber" function but stilled timed it, the time should be less than 1 second. I'm guessing it takes your getNumber function about a second to complete. I would suggest analysing that function instead of the for-loop.
If you are having problems with pointers, try looking at these web resources.
Tutorial on Pointers Tutorial on Pointers WITH PICTURES!!! :)
Pointers are good when you have many copies of a variable - but the copies will all stay the same. Instead of changing many copies, just have them point to the variable instead and change the variable instead.
A good example of a point is URL links. You give the location on where to go. Imagine if you couldn't give the location but had to store the page itself. If that page changed, you have to change ALL the locations where the page is stored. I hope that was a good analogy to explain why pointers can be quicker.