MAMEWorld >> Programming
View all threads Index   Flat Mode Flat  

SpaceB
MAME Fan
Reged: 07/31/07
Posts: 1
Send PM
Re: Help with linked lists
07/31/07 02:11 AM


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







Entire thread
Subject Posted by Posted on
* Help with linked lists sosolidgangstarr 03/29/07 08:39 PM
. * Re: Help with linked lists krick  03/29/07 08:48 PM
. * Re: Help with linked lists SpaceB  07/31/07 02:11 AM

Extra information Permissions
Moderator:  Pi 
0 registered and 115 anonymous users are browsing this forum.
You cannot start new topics
You cannot reply to topics
HTML is enabled
UBBCode is enabled
Thread views: 3442