data-structures

Typeahead / Incremental Search in java

Hello, we've got a list of search-result mappings, e.g. a simple url mapping might look like "stackoverflow" -> "www.stackoverflow.com" "joel" -> "www.joelonsoftware.com" so searching for the exact phrases is working fine. Now we're looking for an incremental search / typeahead, e.g. "stackover" would also return "www.stackoverflow....

Compression Algorithm for Encoding Word Lists

I'm am looking for specific suggestions or references to an algorithm and/or data structures for encoding a list of words into what would effectively would turn out to be a spell checking dictionary. The objectives of this scheme would result in a very high compression ratio of the raw word list into the encoded form. The only output req...

What is a cyclic data structure good for?

Hello, I was just reading through "Learning Python" by Mark Lutz and came across this code sample: >>> L = ['grail'] >>> L.append(L) >>> L ['grail', [...]] It was identified as a cyclic data structure. So I was wondering, and here is my question: What is a 'cyclic data structure' used for in real life programming? There seems to...

Time Calendar Data Structure

We are looking at updating (rewriting) our system which stores information about when people can reserve rooms etc. during the day. Right now we store the start and time and the date the room is available in one table, and in another we store the individual appointment times. On the surface it seemed like a logical idea to store the ...

Implementing a buffer-like structure in Python

I'm trying to write a small wsgi application which will put some objects to an external queue after each request. I want to make this in batch, ie. make the webserver put the object to a buffer-like structure in memory, and another thread and/or process for sending these objects to the queue in batch, when buffer is big enough or after c...

Why isn't System...Stack<T> implemented as a Linked List?

I was looking through my code and I found a couple of extension methods that I wrote in order to remove items from a System.Collections.Generic.Stack. I was curious, so I looked at the source of Stack with Reflector and I can see that they implemented it as an array instead of a linked list and I'm just wondering why? With a linked list ...

ASP.Net MVC and N-Tier

Greetings, Apologies in advance that I have not researched this toughly enough to answer the question myself, but I imagine it would take me some time and I would rather know now before I invest more time in learning it. I couldn't find anything in my initial research.. Why use ASP.Net MVC if your already using a multi-tier architectu...

Broad phase collision detection - Quadtrees, BSP, etc.

Collision detection is naturally an O(n^2) problem. You have a bunch of objects and you need to check if that object is colliding with every other object. Right now that is my naive approach and while it isn't a problem for a limited number of objects I'm now approaching the point that it is a bottleneck (after profiling my code). H...

How to find unique entries in Large data set?

I have 100 million lines of data, the data is a word no longer than 15 chars,one word per line. Those data are stored in multiple files. My goal to to find the unique words among all files. One solution is to import all words into database and add a unique key for the field. but this is too slow for this large data set. Is there any ...

C# Data structure Algorithm

Hi Techies, I recently gave a interview to one of the TOP software company. I was completely stuck with only one question asked by interviewer to me, which was Q. I have a machine with 512 mb / 1 GB RAM and I have to sort a file (XML, or any) of 4 GB size. How will I proceed? What will be the data structure, and which sorting algorith...

Full text indexer with line level results, substring searches, and incremental update support?

I'm looking for a full text indexing package that is being maintained (i.e. not an end of life dead package) that can would ideally have support for: substring matches incremental updates line level results Also ideal would be support for boolean matches adjacency searches "stringX found near stringY" A little more detail about t...

Data structure or algorithm for second degree lookups in sub-linear time?

Is there any way to select a subset from a large set based on a property or predicate in less than O(n) time? For a simple example, say I have a large set of authors. Each author has a one-to-many relationship with a set of books, and a one-to-one relationship with a city of birth. Is there a way to efficiently do a query like "get all...

Fibonacci, Binary, or Binomial heap in c#?

Are there any heap data structure implementations out there, fibonacci, binary, or binomial? Reference: These are data structures used to implement priority queues, not the ones used to allocate dynamic memory. See http://en.wikipedia.org/wiki/Heap_(data_structure) Thanks, Dave ...

Programming Design Help - How to Structure a Sudoku Solver program?

Hi, I'm trying to create a sudoku solver program in Java (maybe Python). I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I j...

Python data structure: SQL, XML, or .py file

What is the best way to store large amounts of data in python, given one (or two) 500,000 item+ dictionary used for undirected graph searching? I've been considering a few options such as storing the data as XML: <key name="a"> <value data="1" /> <value data="2" /> </key> <key name="b"> ... or in a python file for direct acce...

Correct Model Data Structure? (My 1st Rails App)

I'm about to build my first Ruby on Rails application (and first anything beyond xhtml and css), and I'm looking for some helpful feedback on my model structure. I've included a mockup to help visual the application. The only models I'm sure I need so far are: 1. a movie model (to serve as the main model, named movie so URL's will look...

A priority queue which allows efficient priority update?

UPDATE: Here's my implementation of Hashed Timing Wheels. Please let me know if you have an idea to improve the performance and concurrency. (20-Jan-2009) // Sample usage: public static void main(String[] args) throws Exception { Timer timer = new HashedWheelTimer(); for (int i = 0; i < 100000; i ++) { timer.newTimeout(...

I need a slightly different multimap

Hi all, I'm looking for a C++ container class, that's a lot like a multimap, but slightly different. The container would store pairs of strings. But when I retrieve items from the container using key K, I want to find all the items where K begins with the item's own key. E.G. If I use key "abcde" I want to find items with key "adc" ...

'Head First' Style Data Structures & Algorithms Book?

I loved the Head First series book on object oriented design. It was a very gentle and funny introduction to the subject. I am currently taking a data structures class and find the text we are using (Kruse/Ryba Data Structures and Program Design in C++) to be very dry and hard to comprehend. This is mostly due I think to my own limita...

Are there O(1) random access data structures that don't rely on contiguous storage?

The classic O(1) random access data structure is the array. But an array relies on the programming language being used supporting guaranteed continuous memory allocation (since the array relies on being able to take a simple offset of the base to find any element). This means that the language must have semantics regarding whether or n...