问题
I am trying to use a hash table to solve a discrete algorithm problem. I am using Shanks baby step giant step algorithm. My hash table contains about 11,000,000 keys and values. I keep getting an out of memory exception. is there any way to 'fix' this? or a different data structure to use? I am using Visual C# Express 2010 with .NET 4.0 Framework
回答1:
I feel this is cheating somewhat, but Wikipedia gives a solution
"The algorithm requires O(m) memory. It is possible to use less memory by choosing a smaller m in the first step of the algorithm. Doing so increases the running time, which then is O(n/m). Alternatively one can use Pollard's rho algorithm for logarithms, which has about the same running time as the baby-step giant-step algorithm, but only a small memory requirement."
回答2:
Try targeting a 64-bit platform. 32-bit executables often run out of virtual memory space these days.
来源:https://stackoverflow.com/questions/7472130/baby-step-giant-step-algorithm-in-c-hash-table-out-of-memory