data-structures

How to generate half-edge structure representation for a polygonal mesh?

I would like to generate output to display the numeric data of the Half-Edge Structure that is based from an input of polygonal mesh data (in numeric data form). The concept to read the polygonal model basically is like this: For the INPUT, the file is in OFF format and include datas like (a) First part: the number of vertex, number o...

Binary tree that stores partial sums: Name and existing implementations

Consider a sequence of n positive real numbers, (ai), and its partial sum sequence, (si). Given a number x ∊ (0, sn], we have to find i such that si−1 < x ≤ si. Also we want to be able to change one of the ai’s without having to update all partial sums. Both can be done in O(log n) time by using a binary tree with the ai’s as leaf node v...

Data structure that owns objects and returns IDs for them

I need a data structure that manages integer IDs for T objects (typically std::string). It should support getting the ID for some object and, vice versa, get the object for some ID: // if object not seen before: copies and stores object and returns // new ID, otherwise just returns its ID int Add(const T& obj); // if obj not found: ret...

What is the most efficient data structure to store time series of partially changing array?

Hi All, My problem is I have an array of objects of size N. after every time (t+1), some of the values of the array may or may not change. so lets say t+1 index 15 changes but everything else stays the same. What is the most efficient way to store something like this (in memory ) apart from just having an array of arrays of course? I w...

Should I choose a hash, an object or an array to represent a data instance in Perl?

I was always wondering about this, but never really looked thoroughly into it. The situation is like this: I have a relatively large set of data instances. Each instance has the same set or properties, e.g: # a child instance name age height weight hair_color favorite_color list_of_hobbies Usually I would represent a child as a hash ...

Segmentation Fault when deleting complete linked list

Hello, I'm trying to delete whole linked list but getting segmentation fault and not able to detect what is the real problem. When I tried debugging using gdb, it is able to remove the first node but throw segmentation fault when deleting second node. Please suggest me what can be the possible reason. #include <iostream> using namespac...

flatten a dictionary of dictionaries of lists in Python

Hi all... I'm trying to wrap my brain around this but it's not flexible enough. In my Python script I have a dictionary of dictionaries of lists. (Actually it gets a little deeper but that level is not involved in this question.) I want to flatten all this into one long list, throwing away all the dictionary keys. Thus I want to transf...

What is the most logical method to decide upon a value given a set of nested rules? and how do we store it?

Hi there, I'm needing to implement what to me looks like a decision tree (though searching on that term returns posts on finding out influencing factors in a decision process - which isn't what I'm after). The system I'm building will be working out warranty periods to give a product installation based upon some criteria. The requireme...

Skiplast random function need explained

I read about skipList implementation in C++ and I don't understand this random function : float frand() { return (float) rand() / RAND_MAX; } int random_level() { static bool first = true; if (first) { srand( (unsigned)time(NULL) ); first = false; } int lvl = (int)(log(frand())/log(1.-P)); retu...

Nosql DB for undirected graphs?

I want to store a graph of millions of nodes where each node links to another in an undirected manner (point A to B, automatically B points to A). I have examined Neo4j, OrientDB as possible solutions but they seem to be oriented in directed graphs, and Neo4j not being free for >1 million nodes is not a solution for me. Can you help me...

Functional/Immutable Data Structures for the JVM?

Does anyone know of a Java/JVM data structure library providing functional (a.k.a. immutable, or "persistent" in the functional sense) equivalents of the familiar Java data structures? By "functional" I mean that the objects themselves are immutable, while modifications to those objects return new objects sharing the same internals as t...

Disk-based trie?

I'm trying to build a Trie but on a mobile phone which has very limited memory capacity. I figured that it is probably best that the whole structure be stored on disk, and only loaded as necessary since I can tolerate a few disk reads. But, after a few attempts, it seems like this is a very complicated thing to do. What are some ways t...

stack and queue with a link list

I have an assignment where i need to implement a stack and a queue with a link list. How would i go about implementing it? would i use a circular link list and i can add to the head and tail? I wasnt looking for any code handouts and i dont think its fair that i got minus two points for asking a generalized question. This is how i think ...

How to compute the algorithmic space complexity

Hi all: i am reviewing my data structures and algorithm analysis lesson,and i get a question that how to determine to the space complexity of merge sort and quick sort algorithms ? The depth of recursion is only O(lgn) for linked list merge-sort The amount of extra storage space needed for contiguous quick sort is O(n). My th...

How to make an intrusive tree class in C# use generics?

In C# I have an intrusive tree structure that looks like this: public abstract class Node { Container parent; Node nextNode; Node previousNode; public abstract class Container : Node { Node firstChild; Node lastChild; } } The various objects that can be added to the tree inherit from either Nod...

How to store OpenGL Primitives in a tree data structure in C++ ?

I'm new to OpenGL and C++. Say I start with a 2D square (on the very left) like shown in the picture below. I want to make it interactive with the glutKeyboardFunc() so when I press a number a new box will draw next to the corresponding edge. Figure the best way to do this is to have a tree structure that hold all the boxes. But I'm n...

ASP.NET: Multilingual support without resource files.Whats the best approach and data structure ?

I have an asp.net web application which i want have multilingual support now.For some reasons,the management is not ready to use satellite assemblies or resource file.They want to have it table driven.so i created tables to store the text for each part of the page.I dont want to make a call to db every time the page control loads.Ex: if ...

Base classes versus templates versus generated code versus macro's

I have to work out a small framwork that is going to be used by several of our applications. On top of this, the framework is going to be used multiple times within the same application, but with a slightly different configuration. The 'nature' of the configuration is more complex than just having some configuration options and some se...

when is a queue full?

I have seen many ways to check when a queue is full, but I don`t understand any, so in simple words when is a queue full? (If there is a code please make it in C++ or pseudocode) I have this code to check if the queue is full:- myFront != (myBack+1) % max (e.g. why isn`t it simply " myBack == max ") ...

Algorithm find elements not in set

I have a list of products {P1, P2, ...} each of which can have a list of attributes {a1, a2, ...}. What's the fastest algorithm to find all elements NOT having some attributes say {a2, a6, a10}? If P1 = {a1, a2, a3} P2 = {a3} P3 = {a1, a4} , the algorithm should return {P2, P3} The issue is I don't know the input list of attributes ...