General Computer sciene question

  • Thread starter Thread starter kalamantina
  • Start date Start date
K

kalamantina

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 .
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).
 
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.
 
Well my friendI am not taking a course, nor was this a class work, as I
said earlier, I ran across those questions
in some discussions with friends. Now I really don;t anything wrong
with asking a question, I do see a problem with soeone ASSuming
something and
going on a rant on it. I guess you should take it EZ my friend.
 
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 .

what's the problom exactly? and what memory limitation is doing up here?
read the file word by words, and if a word is the right length, keep 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).
There is none.
If there is 2 billion word and you want to print all anagram of all word, I
would say a quick estimate is you will have to print 10 billion word.
You will run out of paper!
So the best solution is to print nothing at all.
On top of that if each page could contains thousands word and cost 0.04$,
printing them all would cost 40 millions dollars, quite a waste of money if
you ask me.
 
Who was ranting my friend the questions cannot be answered as stated for the
reasons I gave you. It would seem that *you* are the one making assumptions
my friend and should take it EZ.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 
Back
Top