Jump to content
Sign in to follow this  
Zilee

Better structure

Recommended Posts

I have an array with 10,000+ elements and it is time to port it into a better structure. Should I code a binary tree or maybe a linked list?The array contains objects and there isn't really much need to display it, so I mostly need a structure with quick data access and quick deletion.

Share this post


Link to post
Share on other sites
so I mostly need a structure with quick data access and quick deletion.
Database?

Share this post


Link to post
Share on other sites
My application's requirements do not allow the use of a DB.
How is your "array" currently stored/generated? Can you use a server-side language?

Share this post


Link to post
Share on other sites

Depending on what your data is, you could use a linked list, a tree (binary, red/black, b-tree, etc), directed graph, hash tables, etc. It depends how your nodes are related to each other and what you're goals are. Look up descriptions of the various data structures to see what their strengths and weaknesses are. A random-access data structure like an associative array is about as quick as you can get for lookups and deletions, but if that doesn't suit your needs for whatever reason, like if you're searching for a specific node but can't use a random-access structure, then you'll need to traverse a tree or list to find what you're looking for.

Share this post


Link to post
Share on other sites
How is your "array" currently stored/generated? Can you use a server-side language?
Yes I use server-side javascript to keep my structure in memory and available to everyone.
Depending on what your data is, you could use a linked list, a tree (binary, red/black, b-tree, etc), directed graph, hash tables, etc. It depends how your nodes are related to each other and what you're goals are. Look up descriptions of the various data structures to see what their strengths and weaknesses are. A random-access data structure like an associative array is about as quick as you can get for lookups and deletions, but if that doesn't suit your needs for whatever reason, like if you're searching for a specific node but can't use a random-access structure, then you'll need to traverse a tree or list to find what you're looking for.
Yes, it seems that a key-value collection will be ideal. I will have to display portions of the array to the user... I think a hash of hashes will be the best.I remember coding in a language that did had severely hindered performance when using multi-dimension arrays, is it the same case with JS? Edited by Zilee

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...