data-structures

Connecting C# (frontend) to an apache/php/python (backend)

Overview: We are looking to write a C# user interface to select parts of our web applications. This is for a very captive audience (internally, for example). Our web applications are written in PHP and/or Python using Apache as the web server. Why? A well thought out native Windows interface can at times be far more effective than li...

How to set a char inside a struct in C?

How do I allocate memory for a char variable (not a char pointer) inside a struct? (Variable names are in portuguese, sorry if it's kinda confusing) I have this struct: typedef struct node{ char rotulo[10], instrucao[1][2][10], flag; int simplificado; struct node *referencias[2]; struct node **antecessores; int n...

Optimizing recursive calls over data structures

Is there an algorithm to optimize a highly recursive function into an iteration over a data structure? For example, given the following function... // template <typename T> class BSTNode is defined somewhere else // It's a generic binary search tree. template <typename T, typename R> void in_order(BSTNode<T>* root, R (*routine)(T)) { ...

Task planning data/object structure

I need to create a database structure for managing a gantt style system of tasks and resources, there are some custom needs and the technology involved doesn't play well with others, so I'm thinking of doing it from scratch. My needs are simple: Tasks, prioritized Resources (just people) Calendars (mostly being able to handle non-worki...

Do you use linked lists, doubly linked lists and so on, in business programming?

Are data structures like linked lists something that are purely academic for real programming or do you really use them? Are they things that are covered by generics so that you don't need to build them (assuming your language has generics)? I'm not debating the importance of understanding what they are, just the usage of them outside ...

Choosing the right data structure for this problem: circular linked list, list, array or something else

The requirement I have is for every type T, I have a number of elements (between 1-30+) and at first I need random item, then I need the next, and when I reach the last item, it should return the first one and so on. So say T is Icon, and the collection is Images (instance). I want to have: // program start: Icon icon = RandomIcon();...

OO Design Question -- Parent/Child(ren) -- Circular?

I'm fairly new to the OO design process, so please bear with me.... I have two entities that I need to model as classes, call them Parent and Child (it's close enough to the actual problem domain). One Parent will have one or more Children -- I have not interest, in this application, in childless Parents. Where my brain is going out to...

Delphi: Mimicking MS OneNote's Data Structure

MS's OneNote uses a data hierarchy that is essentially a simple tree, even though the info is displayed via a tabbed interface rather than a treeview. You begin with "notebooks," which can have "sections," which have "pages." I'm trying to model this. In my case, a page would be linked to the contents of a RichEdit. My problem is not t...

Efficient storage of prime numbers

For a library, I need to store the first primes numbers up to a limit L. This collection must have a O(1) lookup time (to check whether a number is prime or not) and it must be easy, given a number, to find the next prime number (assuming it is smaller than L). Given that L is fixed, an Eratostene sieve to generate the list is fine. Rig...

Trie implementation

Is there any speed- and cache-efficient implementations of trie in C/C++? I know what a trie is, but I don't want reinvent the wheel, implementing it myself. ...

Python: Data Structure for Maintaing Tabular Data in Memory?

Hello, My scenario is as follows: I have a table of data (handful of fields, less than a hundred rows) that I use extensively in my program. I also need this data to be persistent, so I save it as a CSV and load it on start-up. I choose not to use a database because every option (even SQLite) is an overkill for my humble requirement (al...

Representing a tree structure out of a db

Hi to all, I've read about various ways of representing hierarchical structure within a relational database like Adjacency List. I have decided to try a straight forward way like a table (oversimplified) done like this: id | name | parent where parent is a inner reference to id. This should be enough to represent a simple tree of undef...

The data structure for the "order" property of an object in a list

I have a list of ordered objects stored in the database and accessed through an ORM (specifically, Django's ORM). The list is sorted arbitrarily by the user and I need some way to keep track of it. To that end, each object has an "order" property that specifies its order in relation to the other objects. Any data structure I use to sor...

Most appropriate data structure for an ordered list in an RDBMS?

I'm storing an ordered list of several million items in a MySQL database. Reasonably often, items need to be added or removed from the list; equally often, the position within the list of an item must be determined. I'd say the read/write ratio is about 50:50. Starting with a linked-list model, I read [1] and the various models discusse...

Multi-way tree

How do you find the height of a multi-way tree? A binary tree looks something like this... int height(node *root) { if (root == NULL) return 0; else return max(height(root->left), height(root->right)) + 1; } I cant figure it for multi-way. ...

ColdFusion: How to check if a certain element exists in a 2-dimensional array?

I have an 2 dimensional array. I write 3 values into the array during its initialization and i add a fourth value if an array value is not equal with a value passed through a form. Then i want to check, if the fourth value exists. update.cfm <cfset array = obj.getArray() /> <cfif not StructIsEmpty(form)> <cfloop collection="#form#" i...

Any ideas on how to implement flickr's tags clustering system? (preferrably in Rails)

I'm mainly just looking for a discussion of approaches on how to go from decentralized, non-normalized, completely open user-submitted tags, to start making sense of all of it through combining them into those semantic groups they called "clusters". Does it take actual people to figure out what people actually mean by the tags used, or ...

data structure for multi-key data?

is there a commonly used data structure for mult-key data? e.g. (key1, key2, ..., keyN) -> value. I used to use dictionaries of dictionaries (in c#), and then wrote my own wrapper on top of this to make the syntax look a bit nicer. but it seems like I still have to write a wrapper for each N-dictionary, where N is the number of keys, sin...

Parsing an unknown data structure in python

I have a file containing lots of data put in a form similar to this: Group1 { Entry1 { Title1 [{Data1:Member1, Data2:Member2}] Title2 [{Data3:Member3, Data4:Member4}] } Entry2 { ... } } Group2 { DifferentEntry1 { DiffTitle1 { ... } } } Thing is...

C++ data structure with lookuptime O(1), like java's hashmap in stl ?

Is there such a structure in c++ standard library? I don't have access to anything else so unordered_map in tr1 cant be used (and boost etc). What I have is a large number of custom class elements 100000+ which I need to store, and access them very fast O(1) on everage. I can't use arrays/vectors as the elements will be stored randomly ...