data-structures

Best way to remove an entry from a hash table

What is the best way to remove an entry from a hashtable that uses linear probing? One way to do this would be to use a flag to indicate deleted elements? Are there any ways better than this? ...

Best Algorithm for key/value pair where key is an int64 in Delphi, pre Delphi 2009?

I need an algorithm to store a key/value pair, where the key is an Int64. I'm currently using a sorted IntList (same as a TStringList, but stores int64s). This gives me O(log n) for search, Insert and delete operations. Since I don't ever need the items sorted, this is a little inefficient. I need some kind of hashtable for O(1) operatio...

Using loops to create arrays

I am extremely new at php and I was wondering if someone could help me use either a for or while loop to create an array 10 elements in length ...

Passing a value with struct type into a function in C

typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void push(element e, queue s) { nat lt = s->length; if (lt == max_length - 1) { printf("Error in push: Queue is full.\n"); return; } else { s->c...

Way to define List<> of two elements string array?

I want to build two-dimentional array of strings where length of one dimention is 2. Similar to this string[,] array = new string[,] { {"a", "b"}, {"c", "d"}, {"e", "f"}, {"g", "h"} } Doing List<string[]> list = new List<string[]>(); list.Add(new string[2] {"a", "b"}); list.Add(new string[2] {"c", "d"}); list.Add(new...

How to define structure in a tag-based organization?

[former title: Is there a way to force a relationship structure on a tag-based organizational methodology?] I have some entities, and they have a series of attributes. Some of the attributes affect what other attributes the entity can have, many of the attributes are organized into groups, and occasionally entities are requited to have ...

Term for "find, remove and return an element" in a set?

Title says it mostly. I want to add a simple extension method to the base Dictionary class in C#. At first I was going to name it Pop(TKey key), kind of like the Stack method, but it accepts a key to use for lookup. Then I was going to do Take(TKey key), but it coincides with the LINQ method of the same name...and although C# 3.0 lets y...

Is there any standard way of storing vector information in a database?

I want to store a very large amount of vector data on a server and only poll the parts I need at a given point... This shouldn't be a problem. Is there any way to take a vector file like an svg file and import it into a database? I could always write an svg parser to import it into my database, but is there any standard way of doing th...

What is the most common use of the "trie" data structure?

I want to learn more about "trie" data structures. I've read about them on Wikipedia but I'm still confused. What is the most common use? Auto-complete in the address bar of a web browser... or? Cheers! ...

How do I sync the results of a Web service with a DB?

I am looking for a way to quickly compare the state of a database table with the results of a Web service call. I need to make sure that all records returned by the Web service call exist in the database, and any records in the database that are no longer in the Web service response are removed from the table. I have to problems to sol...

How is the NodeList implemented?

The DOM NodeList (as returned e.g. by element.getElementsByTagName) is an interesting object, in that it is not a snapshot, but reflects changes to the document made after you have created the NodeList. I was wondering how one would implement such a collection: Completely lazy evaluation must be horribly slow, but keeping a cached vers...

Definition of a binary search tree

Hey guys, I'm trying to find the definition of a binary search tree and I keep finding different definitions everywhere. Some say that for any given subtree the left child key is less than or equal to the root. Some say that for any given subtree the right child key is greater than or equal to the root. And my old college data struc...

Why Dictionary is preferred over hashtable in C#?

In most of programming languages, we preferred using a dictionary over a hashtable . What are the reasons behind it? ...

Which data structure would you use: TreeMap or HashMap? (Java)

Description | A Java program to read a text file and print each of the unique words in alphabetical order together with the number of times the word occurs in the text. The program should declare a variable of type Map<String, Integer> to store the words and corresponding frequency of occurrence. Which concrete type, though? TreeMap<St...

Efficient persistent data structures for relational database

I'm looking for material on persistent data structures that can be used to implement a relational model. Persistence in the meaning of immutable data structures. Anyone know of some good resources, books, papers and such? (I already have the book Purely Functional Data Structures, which is a good example of what I'm looking for.) ...

Favorite Data Structure

We all, as programmers, have something that we really like and always when we are trying to solve a problem we would like to solve it on our personal choice of programming language/algorithm. But the question that I've chatted with other developers at work about, was "Which is your favorite data structure" so I've met developers who was...

What would you build using a multiway search tree.

I am currently teaching myself about various data strutures and am a little frustrated with the various types of trees. I can understand the purpose of organizing something into binary search trees but don't see any practical application of multiway search trees. Can someone please give some examples of problems they've implemented using...

Appropriate data structure for flat file processing?

Essentially, I have to get a flat file into a database. The flat files come in with the first two characters on each line indicating which type of record it is. Do I create a class for each record type with properties matching the fields in the record? Should I just use arrays? I want to load the data into some sort of data structure...

Good library/libraries for datastructures in assembler

Are there any good libraries (preferably with commented source) for standard datastructures (Linked list, array list, queue, stack etc.) for x86 (or others) in Assembler ? I don't like to reinvent (and debug !) the wheel.... ...

MultiMap implementation

I'm writing a simple IDictionary abstraction in C# that wraps a Dictionary<K, ICollection<V>>. Basically, it maps multiple values to one key. I can't decide whether to remove a key and its empty list when the last item in a values list is removed, or leave it (to avoid instantiating a new collection if the key is reused) and do checks ...