[Javascript] Data Structure implementation

Mike Dougherty mdougherty at pbp.com
Mon Apr 4 22:52:57 CDT 2005


I'd like to add my 2 cents on this thread:

When I first encountered the ideal concepts of arrays, linked lists, btrees, etc. I thought they 
would be fundamental building blocks of writing "real" programs.  They probably would be if the 
"real world" hadn't moved on to 4th and 5th generation programming environments and OOP.  So much 
of the implementation details are now abstracted away from the developer that the concept of using 
an array to implement a linked list is a purely academic exercise.  I do believe the fundamental 
concepts are worthwhile to understand; for the sake of deciding higher-level implementation 
strategies (and that's what [imo] separates a developer from a programmer)  However a greater 
importance should be in developing so-called "best practices" for code readibility, reuse, fault 
tolerance/recovery, and OOPy ideas like subclass/inheritance and object implementaion 
transparency.   

It's almost midnight, so I can't think of a good example to illustrate this idea- so if there are 
any replies (positive or negative) I would enjoy the feedback...
On Tue, 05 Apr 2005 00:04:12 +0100
  james <james at southspace.org> wrote:
>Thanks, that is a fantastic answer to my question!!!
>
>I think I was focusing too much on the way my CS tutor introduced the concept of Linked List as a 
>way to get around the problems of Arrays in C, which are problems that (because javascript Arrays 
>are hashtables), don't really come into the question with JavaScript.
>
>but I see that linked lists have benefits over hashtable style arrays also for many operations
>
>thanks again!
>
>Jenni
>
>At 18:22 04/04/2005 -0400, you wrote:
>>Jenni,
>>
>>On Apr 4, 2005 1:50 PM, james <james at southspace.org> wrote:
>> > I am not really as much of an expert on this as I would like to be
>> > but I would say the reasons for using a linked list structure if for
>> > example you were using C are:
>> >
>> > easy insertions
>> > easy joins
>> > no risk of overflow (so you can for example easily implement a queue)
>> >
>> > the downsides being:
>> >
>> > no direct but only sequential access
>>
>>Well, you are assuming this is a downside. For abstraction and
>>encapsulation purposes, it is often a very desireable consequence. If
>>I pass a method/function a list node, it doesn't have to know anything
>>about the node's position in the list. I have seen many javascript
>>applications that fall all over themselves trying to keep track of
>>indeces, because the developer never thought about anything but an
>>array.
>>
>>I could just as easily turn the question around and ask you why you
>>would ever want an array, and you would likely say: there are
>>situations where direct access is important. But, if you are in a
>>situation where only relative access is important, you are wasting
>>resources if you use an array over a linked list.
>>
>>Then, of course, it is rather difficult to efficiently model a tree
>>structure and similar nonlinear structures in an array. In fact, you
>>waste quite a bit of space in an array implementation unless your tree
>>is full.
>>
>> > but this is in comparison to classic C Arrays, whereas in comparison
>> > to a Hash Table for everything approach of JavaScript, and when you
>> > have compiled into the Javascript interpreter methods like
>> > Array.Splice(), I'm not sure what the benefits are of implementing
>> > such an structure....
>>
>>Yes, I cannot speak to the efficiency of Array.splice(). Maybe do some tests?
>>
>>My point with the "well, hashtables are usually arrays" comment was
>>only that I don't see how the fact that in JS 'arrays' are hashtables
>>in any way encroaches on the usefulness of linked lists.
>>
>> > (oh, and aplogies, I am using a friend's account, my name is Jenny, not 
>> James!)
>>
>>It would seem *I* owe the apologies :)
>>
>>--
>>Matt Warden
>>Miami University
>>Oxford, OH, USA
>>http://mattwarden.com
>>
>>
>>This email proudly and graciously contributes to entropy.
>>_______________________________________________
>>Javascript mailing list
>>Javascript at LaTech.edu
>>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>
>__________________________________________________________
>This message was scanned by ATX
>7:01:45 PM ET - 4/4/2005




More information about the Javascript mailing list