data-structures

Lock-free queue algorithm, repeated reads for consistency

I'm studying the lock-free (en-,de-)queue algorithms of Michael and Scott. The problem is I can't explain/understand (nor the paper does, apart from the comments in the code itself) a couple of lines. Enqueue: enqueue(Q: pointer to queue_t, value: data type) E1: node = new_node() // Allocate a new node from the free list ...

Efficiently retrieving entities that match any element of a set of ids

I'm writing software to provide feedback to people across many categories. For example, I might have 30 employees and 40 standards of evaluation (e.g. "arrives on time," "is polite," "appears to brush his teeth," etc). At arbitrary times, the supervisor can submit a piece of feedback like "employee 3 gets a 5/5 for standard 8 (he smell...

Data structure that supports range based most frequently occuring element query

I'm looking for a data structure with which I can find the most frequently occuring number (among an array of numbers) in a given, variable range. Let's consider the following 1 based array: 1 2 3 1 1 3 3 3 3 1 1 1 1 If I query the range (1,4), the data structure must retun 1, which occurs twice. Several other examples: (1,13) = 1 (...

Binary Tree in C - Troubles

typedef struct node { struct node *leftChild, *rightChild; int value; } bst; void insert(bst* b, int i) { b=malloc(sizeof(b)); b->value=i; b->leftChild = NULL; b->rightChild = NULL; printf("[%i]",b->value); return; } main() { bst* b...

Understanding Fusion Trees?

I stumbled across the Wikipedia page for them: http://en.wikipedia.org/wiki/Fusion_tree And I read the class notes pdfs linked at the bottom, but it gets hand-wavy about the data structure itself and goes into a lot of detail about the sketch(x) function. I think part of my confusion is that the papers are trying to be very general, a...

Finding sorted middle 50% of a sequence (in Boost Accumulators or in other data structure)

For a sequence of values, how would one find the sorted middle 50% of the sequence in Boost Accumulators? For example, let's say that I have the following sequence, 25, 21, 9, 13, 17, 19, 12, 29, 50, 97, 10, 11. The middle 50% data I would like to have is as follows: 13, 17, 19, 21. Of course, one can sort the sequence, which now beco...

Why do we need Deque data structures in the real world?

Can anyone give me an example of situation where a Deque data structure is needed? Please don't explain what a deque is... ...

Mapping C data structures and typedefs to .Net

I'm trying to write an interface for communicating with a network protocol, but the IEEE document describes the protocol at the bit level with information split accross a single byte. What would be the best way to go about handling a C typedef such as typedef struct { Nibble transportSpecific; Enumeration4 messageType; UIntege...

Create a vector of pointers to abstract objects

I'm sure there's a better way to do this. I'm trying to create a class HashTable that is given a size at instantiation, so it can't be given a size at design time, so I can't use an array as my internal representation of the table, as far as I know. So here's what I'm trying to do: #include <vector> #include <iostream> #include "Nodes...

How to represent / Modify 3d solids

In my program I have some cubes (simple, xyz location, xyz size). I want bo be able to take one of these cubes and 'Subtract' another cube from it. So my question, what is a good generic data structure to represent the resulting 3d object, and what kind of algorithm is used to subtract a 3d solid from another? ...

Implementing Scheduling Algorithms with Java

has anyone of you ever dealt with job scheduling problems with Java? I have to work on a resource-constrained project scheduling problem and want to ask for some practical tips. Are there any good libs available for implementing algorithms? What are efficient data structures I should use? edit: It seems like i have not explained it rig...

Finding the no of leaf nodes

An N-ary tree has N sub-nodes for each node. If the tree has M non-leaf nodes, How to find the no of leaf nodes? ...

Data Structure for troubleshooting flow?

What data structure would be best for a non-tree (in the graph theory sense), path-saved, troubleshooting flow for a web troubleshooting site? In plainer words, if I'm wanting to model a troubleshooting flow, such that it's not strictly in a "downward" direction towards a resolution or contact point, is there a more specific structure t...

Haskell Range Map library

Is there a Haskell library that allows me to have a Map from ranges to values? (Preferable somewhat efficient.) let myRangeMap = RangeMap [(range 1 3, "foo"),(range 2 7, "bar"),(range 9 12, "baz")] in rangeValues 2 ==> ["foo","bar"] ...

What is the concatenation complexity of balanced ropes?

I've looked at different papers and here is the information that I've gathered: SGI implementation and C cords neither guarantee O(1) time concatenation for long ropes nor ~log N depth for shorter ones. Different sources contradict each other. Wikipedia claims O(1) concatenation. This page says that concatenation is O(1) only when one ...

Linked list in Pascal

Hi, Im looking for a good and simple implementation of a linked list in Pascal. As Im a Pascal beginner it would help me alot as a study material. Thanks for any tips. ...

Splitting Arrays- is my implementation correct?

I'm writing code for a hybrid data structure for school, and am debugging the code. Basically, this structure is a combination of a Double Linked List and an Array, where each list node contains an array of set size. Since this is an ordered structure, a provision has to be made to identify and split full arrays into equally into two n...

Non-BTree data structure where inserts are done in a sorted manner but i can later remove objects from random places

i want to find an object with O(logN) and also remove with O(log N) - but no go to balanced tree implementation.. any idea's for that? ...

Applications of red-black trees

What are the applications of red-black trees? Is there any application where only RB Trees can be used and no other data structures? ...

How do I implement this graph/tree data structure in C#/SQL?

I need to implement a data structure in C#/SQL Server that is a little bit tree and a little bit graph. I can think of how to brute force this, but performance is very important. That is where I need help. Here are the requirements: 1) There are n root nodes. 2) Each node can have n children. 3) Each node is a list. 4) Each node can...