data-structures

How can I read and parse chunks of data into a Perl hash of arrays?

I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study: Glossina morsitans transcript sequencing project(SRP000741) Sample: Glossina morsitans(SRS002835) Instrument: Illumina Genome Analyzer Total: 1 run, 8.3M spots, 299.9M bases Run #1: SRR016086, 8330172 spots, 299886192 bases 2:SRX004540 Submitte...

K-nearest neighbour with closed-loop dimensions

Hi, I've got a K-nearest neighbour problem where some of the dimensions are closed loops. For example one is 'time of day' and I'm matching for similarity so 'very early morning' is close to 'late evening', you can't just make it a linear scale from 'very early morning' at one end to 'late evening' at the other. How can I represent thi...

Choice of programming language for learning data structures and algorithms

Which programming language would you recommend to learn about data structures and algorithms in? Considering the following: Personal experience Language features (pointers, OO, etc) Suitability for learning DS & A concepts I ask because there are some books out there that are programming language-agnostic (written from a Mathemati...

A datastructure for Robotic Sort

I am trying to solve this problem : https://www.spoj.pl/problems/CERC07S/ I have identified that i need a datastructure in which reversing operations have lesser time complexity. I tried to create one using a doubly linked list, in which (i thought) reversing can be done in O(1) by just changing a value associated with the starting and...

Metalanguage like BNF or XML-Schema to validate a tree-instance against a tree-model

Hi! I'm implementing a new machine learning algorithm in Java that extracts a prototype datastructure from a set of structured datasets (tree-structure). As im developing a generic library for that purpose, i kept my design independent from concrete data-representations like XML. My problem now is that I need a way to define a data mod...

Issue with dynamic array Queue data structure with void pointer

Hi, Maybe there's no way to solve this the way I'd like it but I don't know everything so I better ask... I've implemented a simple Queue with a dynamic array so the user can initialize with whatever number of items it wants. I'm also trying to use a void pointer as to allow any data type, but that's the problem. Here's my code: type...

Interview question: How to detect a loop in a linked list?

Say you have a linked list structure in Java. It's made up of Nodes: class Node { Node next; // some user data } and each Node points to the next node, except for the last Node, which has null for next. Say there is a possibility that the list can contain a loop - i.e. the final Node, instead of having a null, has a referenc...

adjacency list creation , out of Memory error

Hello , I am trying to create an adjacency list to store a graph.The implementation works fine while storing 100,000 records. However,when I tried to store around 1million records I ran into OutofMemory Error : Exception in thread "main" java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOfRange(Arrays.java:...

Use Linq generated classes in business-tier

Context: ASP.NET MVC 2.0, C# At the moment I use following pattern: using (var db = new MyDatabaseDataContext()) { var model = new MyPageModel(); model.player = db.blah.blah.blah; model.info = db.blah.blah.blah; model.bossKillCount = db.blah.blah.blah; } It works fine, one problem is that I have to redefine those mod...

Hashable, immutable

From a recent SO question (see http://stackoverflow.com/questions/2671211/create-a-dictionary-in-python-which-is-indexed-by-lists) I realized I probably had a wrong concept of the meaning of hashable and immutable objects in python. What hashable means in practice?, What the relation between hashable and immmutable is? There are mutab...

create graph using adjacency list

#include<iostream> using namespace std; class TCSGraph{ public: void addVertex(int vertex); void display(); TCSGraph(){ head = NULL; } ~TCSGraph(); private: struct ListNode { string name; struct ListNode *next; }; List...

How do you store sets in Cassandra?

I'd like to convert this JSON to a data model in Cassandra, where each of the arrays is a set with no duplicates: var data = { "data1": { "100": [1, 2, 3], "200": [3, 4] }, "data2": { "k1", [1], "k2", [4, 5] } } I'd like to query like this: data["data1"]["100"] to retrieve the sets. Anyone know how you might m...

Searching temporal data

I developing an application (in C#) where objects are active under a period of time, they have from and to properties of DateTime-type. Now I want to speed up my search routine for queries like: Are there other active objects in this timeperiod/at this time. Is there any existing temporal index I can use or can I use QuadTree/other tre...

Is there a Java data structure that is effectively an ArrayList with double indicies and built-in interpolation?

I am looking for a pre-built Java data structure with the following characteristics: It should look something like an ArrayList but should allow indexing via double-precision rather than integers. Note that this means that it's likely that you'll see indicies that don't line up with the original data points (i.e., asking for the value...

TStringList, Dynamic Array or Linked List in Delphi?

I have a choice. I have a number of already ordered strings that I need to store and access. It looks like I can choose between using: A TStringList A Dynamic Array of strings, and A Linked List of strings (singly linked) and Alan in his comment suggested I also add to the choices: TList<string> In what circumstances is each of the...

What Data structure for Reputation Rules in C# (like stackoverflow)

I am currently building a system which will have entities that will have scores like reputation etc.. I will have a service that will check for certain rules having been triggered, and will perform certain logic if they are triggered. Previously I have used say an Enum for doing this when I have only had to store an id and a descriptio...

Simple C++ container class that is thread-safe for writing

I am writing a multi-threaded program using OpenMP in C++. At one point my program forks into many threads, each of which need to add "jobs" to some container that keeps track of all added jobs. Each job can just be a pointer to some object. Basically, I just need the add pointers to some container from several threads at the same tim...

Collision free hash function for a specific data structure

Is it possible to create collision free hash function for a data structure with specific properties. The datastructure is int[][][] It contains no duplicates The range of integers that are contained in it is defined. Let's say it's 0..1000, the maximal integer is definitely not greater than 10000. Big problem is that this hash functi...

What are Attribute Relational Graphs ?

What kind of data structures are these? Can someone please point out any links or books where I can read more about them. ...

[Visual C++]Forcing memory alignment of variables/data-structures

I'm looking at using SSE and I gather aligning data on 16byte boundaries is recommended. There are two cases to consider: float data[4]; struct myystruct { float x,y,z,w; }; I'm not sure the first case can be done explicitly, though there's perhaps a compiler option I could use? In the second case I remember being able to control pa...