Working with huge text files...

Started by
10 comments, last by Viral_Fury 15 years, 4 months ago
Just to make this a positive example, this is a perfect situation to point out the importance of studying data structures

think about implementing it as either a linked list, or maybe a buffer with a bunch of discriptors.

and loading it all into memory and then working on it is pretty much the only way to go, disk reads are too slow to do that frequently


and the key to searching a large list is sorting
--------------------------------------Not All Martyrs See Divinity, But At Least You Tried
Advertisement
Quote:Original post by godsenddeath
Just to make this a positive example, this is a perfect situation to point out the importance of studying data structures


This I agree with completely. Also take the time to look up algorithms, specifically searches and sorts.

Quote:think about implementing it as either a linked list, or maybe a buffer with a bunch of discriptors.


Please... why would you use a linked list? for a linked list you would have to go through every single, EVERY single element leading up to the word you are looking for. An array or vector is a much better option, but a linear search will still take time. Take some time to look at binary search. It assumes that your list is in order, but it should be. If it's not, take the time to sort it. The O(nlogn-n^2) in preprocessing is well worth the O(logn) vs. O(n) search times.

As viperman1271 said, the hashtable is your BEST option. Instant time retrieval.

This topic is closed to new replies.

Advertisement