Friday, May 21, 2010

How do I write a linked list java program?

The program will read a .txt file and I will need to be able to add and delete from the file.

How do I write a linked list java program?
That one is too hard to explain.





Basic point: you have a "node" that contains pointers to the next or previous node and data. Along with the nodes you usually have a head (beginning node) and a tail (end node).





Pointers: nextNode, previousNode


Data: the data enter from the text file








Check out the API specs on the link below it will give you all of the methods to add/delete/move etc.





One important thing is keep track of your pointers. If you delete a node you have to readjust your pointers to point to the next in line.





Think of your linked list as a line of data with each node pointing to the next node and the previous one also.





Good luck. Data structures programming will stretch your brain to a new place.


No comments:

Post a Comment