1:You have 2 billion words in random order in a file. How to find a
word with n characters length if you have 96M RAM PC and it can read
this file only once .
Define "words." How are these "words" delimited? If you have 2 billion of
them, there are likely to be more than one with n characters in it. Which
one do you want to find? Are these "words" in ASCII or Unicode? Are you
looking for the most elegant solution to this problem? After all, there are
several that would do it.
2: what is the best algorithm to print all the (unique) anagrams for
each word (i.e., for
the word 'rod', produce 'odr', dro', 'rdo', etc).
Define "best." Define "print." Define "algorithm." By "algorithm, do you
mean a"A step-by-step problem-solving procedure, especially an established,
recursive computational procedure for solving a problem in a finite number
of steps?" Or do you mean code?
For both of these question, what platform and what language do you want to
use? Do you want to use the .Net platform? If so, which language? C# and C++
allow for pointer arightmetic, as does MSIL, and probably a few others, but
VB.Net does not. If not the .Net platform, of course, Assembler would be the
most efficient language to use.
Finally, why are you asking these questions? If this is for a course of some
kind, perhaps you could ask your teacher the questions I have listed above.
The questions you've posted cannot be answered without knowing the answers
to these questions. And, if your teacher did ask these questions as stated,
your teacher needs to go back to school. Programming is an exact science,
not a "this is sort of what I mean" science.
And, if you are taking a course, and asking us to solve your problem for
you, you're taking the wrong course. Programming is all about
problem-solving, and *nothing else*. If you can't solve problems on your
own, or you do no want to, you're getting into the wrong business. There are
already too many non-problem-solvers in it as it is.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.