File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Linked-list, binary tree? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Linked-list, binary tree?" Watch "Linked-list, binary tree?" New topic

Linked-list, binary tree?

Bill Norton

Joined: Mar 29, 2001
Posts: 27
I'm wanting to read in a flat text file and then store this information in memory while my app runs. Everyonce in a while I will need to re-write this data back onto the disk. I am not concerned about reading and writing the file(this seems pretty straight forward) but rather how to store this data in a way that is efficient and retrival time is quick. Also, the first and second column would always be different and I would need to be able to get one from the other.
The file might look something like this
smith 1234.12345.12345 workerB
johnson 1223.12121.12122 workerC
There would be approx. 5000 entries like this.
Hopefully this is enough information, and again I am looking for the best data structure to use with Java(I think in C a tree structure was used in this case). But any hints would be welcome.
Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
I think reading the data is pretty much the same, one line at a time. Retrieving is another matter. I also think tree is excellent, almost 1/2 the time to search and retrieve compared to linked list.
Bill Norton

Joined: Mar 29, 2001
Posts: 27
Thanks for the reply.
Does Java have built in classes for trees?
If not is there a class simliar to trees?
I agree. Here's the link:
subject: Linked-list, binary tree?
It's not a secret anymore!