data-structures

How to find intersecting periods in a huge list of periods?

I need an idea for an efficient index/search algorithm or datastructure for a particular problem. So far I could not come up with something fast and elegant... Consider a huge collection of objects with every object having a date period (start / end). Huge as in a few million elements. The element periods can be large or small, they can...

Does Java need tuples?

This question got me re-thinking about something that always bothered me: Does Java need tuples? Do you feel the lack of them in your day-to-day work? Do you think tuples would simplify otherwise complex data structures you find yourself implementing? ...

How to store and search for an IP Address

I have the 4 sources of IP addresses , I want to store them in SQL Server and allow the ranges, that can be categorised by the originating country code, to be maked in an Exclusion list by country. For this I have 2 tables. IPAddressRange CountryCode What I need to know is, if this data was returned to the client then cached for qui...

How to store sets, to find similar patterns fast?

(This is no homework and no work issue. It's just my personal interest/occupation and completly fictional. But I am interested in a good algorithm or data structure.) Let's assume, that I would run a dating site. And my special feature would be that the singles were matched by movie taste. (Why not?) In that case I would need a way to ...

Are there any mature Binary Decision Diagram tools available?

Are there any Binary Decision Diagram (BDD) libraries for C, or other languages that are tested and have good documentation? ...

Database structure for saving search results

I currently work for a social networking website. My boss recently had the idea to show search results by random instead of normal results (registration date). The problem with that is simple and obvious: if you go from one page to another, it's going to show you different results each time as the list is randomized each time. I had t...

Java: Knuth shuffle on a Stack?

Hi, For a programming class I am creating a blackjack program for the first homework assignment. The professor has given us a sample Card class, which includes the method to add them to a deck. For her deck, she uses an ArrayList, which you can easily Knuth Shuffle with the Collections.shuffle() method. That method does not work for St...

How do you represent music in a data structure?

Hey folks, How would you model a simple musical score for a single instrument written in regular standard notation? Certainly there are plenty of libraries out there that do exactly this. I'm mostly curious about different ways to represent music in a data structure. What works well and what doesn't? Ignoring some of the trickier aspec...

XML tree printer?

Is there a program that will print a nicely formatted tree from XML data? I am working on a B+ tree programming assignment for class and it would greatly help if I could visualize the tree. It wouldn't be too hard to output my internal data structure to XML (see below) if there was a program that would render it. ...

Sphere World Implementation C++

What would be the best way to implement, store, and render spherical worlds, such as the ones in spore or infinity but without the in-between stages of spore, and multiple worlds ala infinity universe. Make no assumptions on how the planet itself is generated or its size/scale. ...

Is there a Many to Many Collection in Java using Generics (Domain Model, not Persistence Layer)?

I seem to be using the wrong search terms for this in Google... I have written a Generic Class for Many-To-Many Associations, but I'm guessing this has already been done. It is highly likely that it exists in an implementation much better than my own. This is my first foray into writing a generic class. For a better idea of what I'm ...

Data structures in JDK, under what scenario which one to use?

Does there exist a cheat sheet for data structure like TreeMap, SortedMap, HashSet etc and under what circumstances which one to use. Are there good articles you recommend ...

What's a good way to start learning about Data Structures & Algorithms?

I would like to learn more about Data Structures & Algorithms. Can anyone suggest a good starting point? ...

Best C# data structure for random order population?

In C# I have a use case where I have a mapping from ints to collections. the ints are a dense (but not packed) set from 1 to n where n is not known. The cells will be loaded in random order. the marginal cost of each cell should be ideal (as good as a List<T> or T[]) I'd like to have the cells default filled on demand What is the bes...

What is the CS definition of a Php Array?

From a strictly implementation and computer science point of view how would you classify the Php array datastructure? Is it an associative array? a hash? a dictionary? ... ? ...

Strategy to find your best route via Public Transportation only?

Finding routes for a car is pretty easy: you store a weighted graph of all the roads and you could use Djikstra's algorithm [1]. A bus route is less obvious. With a bus you have to represent things like "wait 10 minutes for the next bus" or "walk one block to another bus stop" and feed those into your pathfinding algorithm. It's not eve...

C++: What would be an appropriate solution to forming a collection of different data types?

I'm writing a command line interpreter and I'm trying to setup formats for individual commands. I have things like the name of the command, the maximum amount of parameters and the minimum amount of parameters. I want to have sort of collection, a sort of prototype of what kind of types the parameters are. My first thought was just to d...

In-order tree traversal

I have the following text from an academic course I took a while ago about in-order traversal (they also call it pancaking) of a binary tree (not BST): In-order tree traversal Draw a line around the outside of the tree. Start to the left of the root, and go around the outside of the tree, to end up to the right of the root. ...

Moving a system from sort of a class system to an MVC format

I am working on a fairly large system developed by another programmer who no longer works here. And since i am the manic serial killer who is maintaining it and knows where he lives. But fun things aside, the system is kinda developed as a class system and kinda not and i have already setup a developer version and can deploy new versi...

Data structure for storing strings?

I'm looking for a data structure to store strings in. I require a function in the interface that takes a string as its only parameter and returns a reference/iterator/pointer/handle that can be used to retrieve the string for the rest of the lifetime of the data structure. Set membership, entry deletion etc. is not required. I'm more co...