data-structures

how to make data structures persistent in c++?

how to make data structures(like trees, graphs ) persistent in c++? ...

Easy applications for learning Java Data Structures

I have been struggling to think of some decent uses for things like vectors and stacks. Since I find myself best able to remember things once i've done something useful with it. I was after some short but useful applications you've found for several of the java data structures. I'm not after any code samples, but more things that stick ...

Reading and Writing Structures [C]

IMPORTANT EDIT: Sorry everyone, i made a big mistake in the structure. char *name; is meant to be outside of the structure, written to the file after the structure. This way, you read the structure, find out the size of the name, then read in the string. Also explains why there is no need for a null terminator. However, i feel somewhe...

Most efficient way to count occurrences?

I'm looking to calculate entropy and mutual information a huge number of times in performance-critical code. As an intermediate step, I need to count the number of occurrences of each value. For example: uint[] myArray = [1,1,2,1,4,5,2]; uint[] occurrences = countOccurrences(myArray); // Occurrences == [3, 2, 1, 1] or some permutation...

Different Types of Linked Lists!

What are the different types of Linked Lists which are commonly used? I know and have used the following: Singly Linked List Doubly Linked List Circular List What are the other kinds of lists that have been used by you or known to you? ...

Need to traverse matrix-like graph in expanding concentric squares...

Ok, I've a data structure that consists of a matrix of linked nodes, lets say 10x10. I would like to be able to choose any of these nodes arbitrarily, and - from there - process a number of the surrounding nodes following the pattern of expanding concentric squares (I used less nodes below for illustration purposes). As far as specifics ...

What is the behavior of ruby Hash#merge when used with a block

It does not seem to be documented very much: hsh.merge(other_hash){|key, oldval, newval| block} → a_hash http://ruby-doc.org/core/classes/Hash.html#M002880 ...

Why is it preferred to use Lists instead of Arrays in Java?

Many people and authors suggested to us to use list than array. List <Integer> list = new ArrayList<Integer>(); list.addElement(1); .... What it is the reason behind it? ...

Cocoa's NSDictionary: why are keys copied?

All objects used as keys in NS(Mutable)Dictionaries must support the NSCopying protocol, and those objects are copied when they're used in the dictionary. I frequently want to use heavier weight objects as keys, simply to map one object to another. What I really mean when I do that is effectively: [dictionary setObject:someObject forKe...

Given N points in a 3D space, how to find the smallest sphere that contains these N points?

Given N points in a 3D space, how to find the smallest sphere that contains these N points? ...

algorithm to find independent sets

Folks, I have a problem. I am a writing a script in python which consists of several modules. Some of the modules are dependent on other modules, hence they should be run only after the dependent modules are successfully run. So each modules derives from a base class module and overrides a list called DEPENDENCIES which is a list of depe...

How to store a table of equivalent values in C# for optimal use in my example?

ENVIRONMENT: C# I have a table of equivalent values, like this: CHEVR = CHEVROLET MERCE = MERCEDES ALFA = ALFA ROMEO [...] I have this data in a tab delimited file. I also have a table with about 15M rows, which contains informations about car parts. One of these is the first row from the equivalent values table (CHEVR, MERCE, ALFA,...

How to Create Own HashMap in Java?

I know about hashing algorithm and hashCode() to convert "key" into an equivalent integer (using some mathematically random expression) that is then compressed and stored into buckets. But can someone point me to an implementation or at least data structure that should be used as baseline? I haven't found it anywhere on the web. ...

simple java hierarchical problem

Hi All, I am having a problem to deal with following data. 1 a 0.64 3 2 d 0.76 3 3 e 0.46 3 1 k 3.43 9 2 i 4.37 9 1 j 0.43 5 2 h 4.74 5 3 j 7.44 5 4 p 3.47 5 1 k 8.33 4 it has 4 column. First is just id for each group. 4th colum is group id while float value is just value and 2nd column too. Here is what I am trying to do: I want to...

java or php tip for small problem

Hi All, I am having a weird mind gogling problem. Sorry in advance, If I confuse you. I have following data 1 3 5 5 1 2 2 4 8 3 2 9 3 8 4 first column = source 1 second column = source 2 third column = result column First and second column will can create 3rd column and that 3rd column can be used in 1st or 2nd column to make a new...

Spatial index for geo coordinates?

What kind of data structure could be used for an efficient nearest neighbor search in a large set of geo coordinates? With "regular" spatial index structures like R-Trees that assume planar coordinates, I see two problems (Are there others I have overlooked?): Wraparound at the poles and the International Date Line Distortion of distan...

How to do a range query

I have a bunch of numbers timestamps that I want to check against a range to see if they match a particular range of dates. Basically like a BETWEEN .. AND .. match in SQL. The obvious data structure would be a B-tree, but while there are a number of B-tree implementations on CPAN, they only seem to implement exact matching. Berkeley ...

Database structure - is mySQL the right choice?

Hi everyone, We are currently planning the database structure of a quite complex e-commerce web app that has flexibility as its main cornerstone. Our app features a large amount of data (products) and we have run into a slight headache trying to keep performance high without compromizing normalization rules in the database, or leaving ...

basic json > struct question ( using 'Go')

I'm working with twitter's api, trying to get the json data from http://search.twitter.com/trends/current.json which looks like: {"as_of":1268069036,"trends":{"2010-03-08 17:23:56":[{"name":"Happy Women's Day","query":"\"Happy Women's Day\" OR \"Women's Day\""},{"name":"#MusicMonday","query":"#MusicMonday"},{"name":"#MM","query":"#MM...

To have an Integer pointing to 3 ordered lists in Java

Which datastructure would you use in the place of X to have efficient merges, sorts and additions as described below? #1 Possible solution: one HashMap to X -datastructure Having a HashMap pointing from fileID to some datastructure linking word, wordCount and wordID may be a good solution. However, I have not found a way to implement i...