![]() |
| ||
| Binary Search on a text file Hi, Can someone please help me. I have a really large text file that contains a list of hash values, it has about ten million entries. I wanted to do a binary search on this to check if a particular hash value is present in the file and to return true if it is and false if not. i have tried to write a binary search and have a small text file with nine entries. the problem i am having is that i don't know how to get it to jump to the middle of the file to begin the search from there without loading it into memory. any help would be greatly appreciated, thanks, Kedklok. Here's the code i tried:
|
| ||
| Re: Binary Search on a text file Hi, i got it to jump to the middle of the file. does anyone know how i would extract the string located at this point and compare it to my test string. thanks, scoobie |
| ||
| Re: Binary Search on a text file Shouldn't this: if(array[middle]==(searchItem)) be this: if (array[middle].equals(searchItem)) If the length of the hash code is the same for all entries, then you should be able to determine the amount of bytes you need to skip. //8 characters plus 1 line-terminated character (\r, \n) |
| All times are GMT -4. The time now is 11:20 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC