sosolidgangstarr: Have you ever done C/C++ programming before? Do you understand what an array is? I don't know much java, but what I wrote below should apply to java or c++ (I think java actually has support for dynamic arrays).
In C, linked lists are very similar to arrays, with one major improvement: they're allocated at run-time, whereas arrays size is set at compile time. In plain English, this means that, you don't need to know how many items you need to store before using the linked list, but you DO with an array. For instance, let's say you wrote the following code in C to store a list of movie titles (strings) in an array:
#define NUM_MOVIES 50
String titles[NUM_MOVIES];
This works fine as long as you only need to store 50 titles. If you're reading the titles from a database, though, there could be as many as 1,000 titles stored there. For this reason, linked lists are usually the better way to go.
In other words, only use arrays when the size is known beforehand and never changes (ie, storing a rectangle as 4 points). For everything else, use linked lists.
> > I do not understand the concept of linked lists and binary trees in particular in > > relation to Java. > > > > I just need general information if anyone can help me out. > > > > Thank you. > > The language doesn't matter, the concept is the same. Just pick up the nearest "data > structures and algorithms" textbook. > > Both are composed of "nodes" each node holds data, and one or more "links" to other > nodes. The links are typically the phyical memory address of the node in question. > > http://en.wikipedia.org/wiki/Linked_list > http://en.wikipedia.org/wiki/Binary_tree
|