data-structures

Java or php tree structure problem

Hi All, I have all my data in my database. It has following 4 columns id source_clust target_clust result_clust 1 7 72 649 2 9 572 650 3 649 454 651 4 32 650 435 This data is like tree structure. source_clust and target_clust generate target_clust. target_clust can be source_cl...

Store address dynamic array in c

I'm trying to save the address of a dynamic array index. The last line of this function is what gives the pointer error. static struct sstor *dlist struct node *ins_llist(char *data, struct llist *l) { struct node *p, *q; q = malloc((size_t)sizeof(struct node)); if(q == NULL) return(NULL); if(ins_list(data, &dli...

Fastest way to represent a collection of bits in PHP?

What is a good way to represent a collection of bits? I have a set of various on/off toggles (thousands of them) and need to store and retrieve their state. The naïve implementation would be an array of booleans, but I'm wondering if there's a better way (better in terms of access speed and/or memory requirements). I've found this BitA...

Deleting an element from a kd-tree of two dimensions.

I would like to extend a kd-tree (2D) class to be able to remove nodes (points). This removal should be conducted without having to rebuild large sections of the tree. The algorithm described in these slides, on slide 13 seems to be what I am after. However, I am trouble following the description of "findmin()" found on slide 7, which is...

Are there some better ways to implement find as you type in Java with a fairly small data set?

Hi, I've got about 2500 short phrases in a file. I want to be able to find phrases as I type possible substrings of them. My app has a text box and a list of phrases. The text box is initially empty and the list contains all 2500 phrases, since the empty string is a substring of all of them. As I type in the text box, the list updat...

What's the connection between the heap used in dynamic memory allocation and the data structure?

Possible Duplicate: Why are two different concepts both called heap? I've googled around, but cannot find the answer for this question; what's the connection between the heap used in dynamic memory allocation and the data structure? Is memory organized on the heap in a way which is similar the the heap data structure? If so, t...

A better way to compare XML docs?

In my current project we have a large repository of content that was originally published in book form. Much of this content was published in both English and many foreign languages, using mostly Quark Express and later InDesign. This content was exported into a custom XML structure for storage and future use. The issue is that the Engli...

Java built-in data structure for mapping adjacent rooms

Hi I'm looking for a Java built-in data structure that would be the best at handling adjacent rooms. I have a grid/floor divided into randomly generated rooms like so: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ...

Practical to save thousands of data structures in a file and do specific lookups?

There's been a discussion between me and some colleagues that are taking the same class as me (and thus have the same project) about saving data to files and read from those files only when we need that specific data. For instance, the project is something about managing a social network. I'm not going into specifics because it doesn't ...

Algorithm used by browser for searching words in the webpage

Hi, Which data structure or algorithm is used in browsers to search for a word? Will the browsers construct a trie or suffix tree? Thank you Bala ...

Algorithm used for auto-suggest feature

Hi, Which algorithm or data structure is used in auto suggest feature to display list of words. I am thinking that edit-distance will be used to display this, but again frequency or score associated with each word should also be considered. For example, consider the tags option on the ask question page. Thank you Bala ...

Bidirectional Map in Cocoa

Cocoa provides NSDictionary, which essentially is an associative array. Is there a nice way to get bidirectional associativity? i.e. one way would have been if NSDictionary had a keyForObject: method which mirrored the behavior of objectForKey:. I don't really care if NSDictionary is not the way to get this. I know NSDictionary does pr...

LinkList Pointer

I have a linklist A->B->C->D my head pointer is on A i want to delete node c with only one head pointer. i dont want any code just explanation. ...

To have efficient many-to-many relation in Java

How can you make the efficient many-to-many -relation from fileID to Words and from word to fileIDs without database -tools like Postgres in Java? I have the following classes. The relation from fileID to words is cheap, but not the reverse, since I need three for -loops for it. My solution is not apparently efficient. Other options ...

Should I use a Dictionary for collections with 10 items or less, or is there a better alternative?

I have a list of objects and I need to find an object as quickly as possible (by it's name property). What data-structure should I use? I know I can use a Dictionary, but there wont ever be more than 10 items in the list, and if I remember correctly the dictionary is implemented as an array if the collection contains 10 items or less. T...

How does OS handle a python dict that's larger than memory?

I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need...

help with lists?

im learning linked lists in java but am stuck on the following Before deleting Hobnobs: bourbon, shortbread, Hobnobs, oreos After deleting Hobnobs: bourbon, shortbread, oreos i would like to create a delete method that will delete the intermediate node "Hobnobs". ive got this so far public class Biscuit { private BiscuitNode firs...

data structure for auto-completion

What are good data structures for auto-completion algorithms? What data structures allow for efficiently finding strings containing a particular substring? ...

When does it make sense to use a map?

I am trying to round up cases when it makes sense to use a map (set of key-value entries). So far I have two categories (see below). Assuming more exist, what are they? Please limit each answer to one unique category and put up an example. Property values (like a bean) age -> 30 sex -> male loc -> calgary Presence, with O(1) pe...

Under what circumstances are linked lists useful?

Most times I see people try to use linked lists, it seems to me like a poor (or very poor) choice. Perhaps it would be useful to explore the circumstances under which a linked list is or is not a good choice of data structure. Ideally, answers would expound on the criteria to use in selecting a data structure, and which data structures ...