MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Threaded Mode Threaded  

Pages: 1

sosolidgangstarr
MAME Fan
Reged: 03/29/07
Posts: 1
Send PM


Help with linked lists
#106641 - 03/29/07 08:39 PM


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.



krick
Get Fuzzy
Reged: 02/09/04
Posts: 4235
Send PM


Re: Help with linked lists new [Re: sosolidgangstarr]
#106643 - 03/29/07 08:48 PM


> 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



GroovyMAME support forum on BYOAC



SpaceB
MAME Fan
Reged: 07/31/07
Posts: 1
Send PM


Re: Help with linked lists new [Re: krick]
#119572 - 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


Pages: 1

MAMEWorld >> Programming
Previous thread Previous  View all threads Index   Next thread Next   Threaded Mode Threaded  

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