in reply to Iterating through Two Arrays. Is there a better use of memory?
What method of comparison is the fastest and least straining on memory if each of the strings were at least 1,000 unique values in length?"Which many problems, you will have to make a trade-off. Do you go for speed, or do you go for less memory. More often than not, there isn't an algorithm that is both the fastest, and uses the least memory.
It's entirely possible to use an algorithm that uses O(1) memory (not counting disk space). It will be the least straining on memory - but it's not the fastest. Fastest will be to put the strings of one set in a hash, and checking with the other set. But that uses more memory.
So, make your pick. The least straining on memory, or the fastest. You cannot have both.
|
|---|