data-structures

Stack and Queue, Why?

Why and when should I use stack or queue data structures instead of arrays/lists? Can you please show an example for a state thats it'll be better if you'll use stack or queue? Thanks. ...

How to walk two arbitrarily complex tree structures simultaneously and create a superset?

I have two tree structures that represent snapshots of a directory structure at two different points in time. Directories may have been added, removed or modified between the snapshots. I need to walk the two trees simultaneously and mark the newer with the differences between the two - i.e. flag nodes as New, Modified, Deleted, Unchange...

High volume queryable and traversable data structure

I'm building an application and need a data structure of interconnected objects that can be queried and traversed. The connections between objects can be arbitrary and not necessarily known before hand. I need this data structure to be queryable (what usual SQL provides) and also traversable (what new graph database like neo4j provide)...

AVL TREE in c++

I have a problem with this very simple block of code. please give me your advice . (My this problem is solved, and in solving this problem the person having id stakx really helped me, the only problem was that i was using stack< treeNode >, when i saw the push method of the stack carefully, there is a copying process when i write head->o...

Which Mathematics should I study to be a better programmer/developer?

Possible Duplicates: How much mathematics and physics should a programmer know? What are the core mathematical concepts a good developer should know? I would like to study mathematics to be a better programmer (Web Developer) but which maths should I study e.g. Algebra, Calculus, Discrete Math etc? I plan to work with Algori...

Why are linked lists almost always used with separate chaining?

It seems as though every time I see a mention of separate chaining in a hash table, a linked list is used as the data structure to store items with collisions. Why is this? For instance, why couldn't you use a vector/array data structure? ...

Csv Calculation using java

Hi all, Thanks for reading my question. I have a CSV file, I read it and store it in a variable. Now i just want to PLUS all the column to see its sum. For example 3,34 12,673 23,8543 SUM ------------- 965,12658 Columns and rows can be N limit. Looks easy but don't know, its taking my all time. Please do let me know which data s...

Storing large amounts of data: DB or File System?

Hello, Let's say my application creates, stores and retrieves a very large amount of entries (tens of millions). Each entry has variable number of different data (for example, some entries have only a few bytes such as ID/title, while some may have megabytes of supplementary data). Basic structure of each entry is same and is in XML for...

Circular Linked List in Cocoa

Is there something similar to a circular linked list available in Cocoa? I know that an NSArray is ordered - but I don't think I can use 'nextItem' or 'previousItem' - correct? Furthermore, I need the nextItem of the last item to be the first item. I could add my own nextItem and previousItem methods, but I'm surprised if Apple have...

How to create array-like data-structures with object keys in PHP?

I want create arrays with object keys in PHP, i.e. something like this: <?php $keyObject = new KeyObject; $valueObject = new ValueObject; $hash = array($keyObject => $valueObject); However, this raises an error. Arrays may only have integer or string keys. I end up having to do something like: $hash = array( 'key' => $keyO...

user activity database structure

Hello. I am working on a community website. I want to show the user's activity in 2 places in the website. The User "A" Profile. The Friends page of the user "A" friends. "What are your friends doing?" The tables for instance are: members members_gallery members_videos members_friends my problem is in the Sql structure. I've ...

Meshing of Point Clouds from a 3Dlaser scanner

Is there any package/software which can do Meshing of Point Clouds in real time? What is the data structure used to represent 3D Point Clouds ? ...

O(1) lookup in non-contiguous memory?

Is there any known data structure that provides O(1) random access, without using a contiguous block of memory of size O(N) or greater? This was inspired by this answer and is being asked for curiosity's sake rather than for any specific practical use case, though it might hypothetically be useful in cases of a severely fragmented heap....

the patterns used in iterators

I am familiar with the usage of C++ STL iterators, e.g. for(map<pair<int,int>>::iterator it=m.begin(); it!=m.end(); ++it) int a = it->first; int b = it->second; But I don't know the inner details in it. Could some explain to me? Either in C++, Java, C# or Python. ...

Efficient method to retrieve all permutations of a tree structure

Edited for a larger tree, for more examples. I have a tree structure that I need to generate all of the possible permutations of, with some restrictions. Given a tree like this: A1----(B1, B2) \ \___(C1) \__(E1, E2) / - A2----(B3, B4) \ \ \ \ \__(D1) \ \_(F1, ...

Display GridView with many columns as two sets of columns

I apologize for the odd title. I've been trying to figure out how to do this and can't quite put it into words. Basically, I need to try to display a GridView with a whole bunch of columns (37 in one case) in two "rows" of columns. More or less. So instead of this: Column1 Column2 Column3 Column4 Column5 Column6 Data Data Data ...

Data structure for efficiently returning the top-K entries of a hash table (map, dictionary)

Here's a description: It operates like a regular map with get, put, and remove methods, but has a getTopKEntries(int k) method to get the top-K elements, sorted by the key: For my specific use case, I'm adding, removing, and adjusting a lot of values in the structure, but at any one time there's approximately 500-1000 elements; I want ...

How to store a sequence of timestamped data?

I have an application that need to store a sequence of voltage data, each entry is something like a pair {time, voltage} the time is not necessarily continuous, if the voltage doesn't move, I will not have any reading. The problem is that i also need to have a function that lookup timestamp, like, getVoltageOfTimestamp(float2second(922...

Writing an Inverted Index in C# for an information retrieval application

I am writing an in-house application that holds several pieces of text information as well as a number of pieces of data about these pieces of text. These pieces of data will be held within a database (SQL Server, although this could change) in order of entry. I'd like to be able to search for the most relevant of these pieces of inform...

Minimal-locking thread-safe hashtable?

Are there any available implementations of a Hashtable that provide thread safety with minimal locking in .NET? Or in another language that can be ported to .NET? We're looking for something in between using a BCL Dictionary<,> class with lock() and a distributed caching application like memcached or Velocity. The intended use is for ...