data-structures

Best hash table for insertion and lookup only

Hi, I want to make a hash table that allows insertion and lookup only. Once something is in the table, it is in for good, unless you make a new hash table and refill the contents. Is there any algorithms/data structures that are more suited for this (over say B-tree/RB-tree/LLRB-tree)? Better would be like - faster insertion and lookup t...

Loading XML Files into VB.Net Structures

I have many, (15-20) different XML files that I need to load to VB.Net. They're designed as they would be in a database; they're designed in Access and bulk exported into XML files. Each file represents a different table in the database. Now, I need to load this information into VB.Net. Initially, I'd love to use DAO and access the M...

Joining very large lists

Lets put some numbers first: The largest of the list is about 100M records. (but is expected to grow upto 500). The other lists (5-6 of them) are in millions but would be less than 100M for the foreseeable future. These are always joined based on a single id. and never with any other parameters. Whats the best algorithm to join such list...

Mapping and reverse mapping

Is there a data structure that can replace the following two maps: Dictionary<TypeA, TypeB> map; Dictionary<TypeB, TypeA> reverse_map; so that I will always be able to get TypeB from TypaA, and TypeA from TypeB? My current solution requires adding key->value to map 1 and value->key to map 2. ...

Convert Binary Tree -> BST (maintaining original tree shape)

I have a binary tree of some shape. I want to Convert it to BST search tree of same shape. Is it possible? I tried methods like - Do In-order traversal of Binary Tree & put contents into an array. Then map this into a BST keeping in mind the condition (left val <= root <= right val). This works for some cases but faile for others. ...

Representing relational tables in ActionScript 3.0

I'm struggling to make a flexible data structure (like a relational database) for a quiz in ActionScript 3.0. I have a number of questions, each with 2 alternatives: Questions | id | alt1 | alt2 | correctAlt | --------------------------------------- | 0 | Sweden | Denmark | 1 | | 1 | Norway | Finland | 2 |...

merge sort using inplace merging

A[] -> 1 3 5 7 2 4 6 8 // lb=0,mid-1=3,mid+1=4,ub=7; a=3,b=7,ab=7; 1st iteration a=3,b=6,ab=6; 2nd iteration swap(A[ab],A[a]) // int t; t i'll using for temporary storage 1 3 5 6 2 4 7 8 b=5,ab=5; sort(A,lb,mid-1); // using bubble sort 3rd iteration swap(A[ab],A[a]) 1 3 5 4 2 6 7 8 b=5,ab=4 sort(A,lb,mid-...

Many-to-many data structure in Python

I have a data set of books and authors, with a many-to-many relationship. There are about 10^6 books and 10^5 authors, with an average of 10 authors per book. I need to perform a series of operations on the data set, such as counting the number of books by each author or deleting all books by a certain author from the set. What would ...

which one is suitable datastructure

Two files each of size terabytes. A file comparison tool compares ith line of file1 with i th line of file2. if they are same it prints. which datastructure is suitable. B-tree linked list hash tables none of them ...

What is the name of a data structure looking like bowling pins?

First of all, sorry for the title. Someone please propose a better one, I really didn't know how to express my question properly. Basically, I'm just looking for the name of a data structure where the elements look like this (ignore the dots): ......5 ....3...2 ..4...1...6 9...2...3...1 I first thought it could be a certain kind of...

Lowest Common Ancestor of Binary Tree(Not Binary Search Tree)..

I tried working out the problem using Tarjan's Algorithm and one algorithm from the website: http://discuss.techinterview.org/default.asp?interview.11.532716.6, but none is clear. Maybe my recursion concepts are not build up properly. Please give small demonstration to explain the above two examples. I have an idea of Union Find data-str...

data structure to speed in-memory tagged object search on boolean function of tags?

If I have a set of tags (<100), and a set of objects (~25000), where each object has some sub-set of the tags, do you know of an existing data-structure that would allow for fast retrieval of those objects that satisfy some boolean function of the tags? Addition/deletion of tags and objects need not be particularly fast, but selection o...

Grid data structure

Usually ‘expandable’ grids are represented as list of lists (list of rows, each row has list of cells) and those lists are some kind of linked lists. Manipulating (removing, inserting) rows in this data structure is easy and inexpensive, it’s just matter of re-linking previous nodes, but when it comes to columns, for instance removing...

Choice of Data Structure

I need to have a list(array, ect) of objects that have a static values. What is the best way (more usefull) to organize such data structure on c#? Now, I am able to do it using two ways: 1) Enumarations with an additional parameters: http://www.codeproject.com/KB/cs/stringenum.aspx 2) Create some class with needed fields and then create...

Is there a data structure with these characteristics?

I'm looking for a data structure that would allow me to store an M-by-N 2D matrix of values contiguously in memory, such that the distance in memory between any two points approximates the Euclidean distance between those points in the matrix. That is, in a typical row-major representation as a one-dimensional array of M * N elements, th...

How to store molecules in memory?

I want to store molecules in memory. These can be simple molecules: Methane (CH4) C-H bond-length: 108.7 pm H-H angle: 109 degrees But also more complex molecules, like paracetamol (C8H9NO2): How can I store molecules in memory, including all bond-lengths and angles? A good idea to store atom-structs in an array? Or is there a be...

Best data structure to store one million values?

Please mention time complexity and best data structure to store these values, when values are: Integers Strings (dictionary like sorting) I know Counting sort is preferred when integers are in a small range. Thanks. Edit: Sorry, I asked a bit different question. Actual question is what would be the best data structure to store the...

Where should I break up my user records to keep track of revisions

I am putting together a staff database and I need to be able to revise the staff member information, but also keep track of all the revisions. How should I structure the database so that I can have multiple revisions of the same user data but be able to query against the most recent revision? I am looking at information that changes ra...

Compile Error in VS2010 while testing LinkedLists

Hi all, I'm doing some tests to a LinkedList, that has two pointers: one point to the next item in the list and the other point to a random node within the list. Here is the code: struct Node { Node* pNext; // a pointer to the next node in the list Node* pReference; // a pointer to a random node within the list int num...

Typedef issue with bison and gnu flex

In my parser, I have %union { SYMTABLE *p_entry ; QUAD *p_quad ; } ; Now, SYMTABLE is the typedef for a struct. The struct and typedef are in an included file. There are no issues with this. QUAD is the typedef for a struct (typedef struct quad QUAD). The struct and typedef are in an included file. There is no problem doing: b...