data-structures

Which data structure should I use? (.NET)

Here is the structure of the data my object will need to expose (the data is NOT really stored in XML, it was just the easiest way to illustrate the layout): <Department id="Accounting"> <Employee id="1234">Joe Jones</Employee> <Employee id="5678">Steve Smith</Employee> </Department> <Department id="Marketing"> <Employee id="3223"...

C# Datastructure for multiple unit conversions

I have a c# app and I need to convert between 3 different units (say for example: litres, Gallons and Pints). The app needs to know about certain volumes of liquid say: 1 pint, 10 pints, 20 pints and 100 pints. I intend to do the calculations and hard code the values (not ideal but necessary), Im looking for a datastructure that will...

What is validating a binary search tree?

I read on here of an exercise in interviews known as validating a binary search tree. How exactly does this work? What would one be looking for in validating a binary search tree? I have written a basic search tree, but never heard of this concept. Thanks ...

Finding last element of a binary heap

Hello everybody, quoting Wikipedia: It is perfectly acceptable to use a traditional binary tree data structure to implement a binary heap. There is an issue with finding the adjacent element on the last level on the binary heap when adding an element which can be resolved algorithmically... Any ideas on how such an ...

How would you represent a Rubik's Cube in code?

If you were developing software to solve a Rubik's Cube, how would you represent the cube? ...

What are the lesser known but cool data structures ?

There a some data structures around that are really cool but are unknown to most programmers. Which are they? Everybody knows linked lists, binary trees, and hashes, but what about Skip lists, Bloom filters for example. I would like to know more data structures that are not so common, but are worth knowing because they rely on great ide...

Datastructures used in DBMS

What are the datastructure used in DBMS like Oracle,MySQL & Sqlite for storing and retrieving records. ...

What type of OO data structure should I use for this string data?

Let's say my program is always passed a string of characters that represents a data table in Wiki syntax. Something like: {||Client:||ABC|-|Contact:||Joe Smith|-|Current revision:||1.0||} I don't want each one of my specific Wiki table objects (e.g., ClientContactTable, CustomerOrderTable, etc.) to know how to parse out | and - and...

Has anyone actually implemented a Fibonacci-Heap efficiently?

Has anyone of you ever implemented a Fibonacci-Heap? I did so a few years back, but it was several orders of magnitude slower than using array-based BinHeaps. Back then, I thought of it as a valuable lesson in how research is not always as good as it claims to be. However, a lot of research papers claim the running times of their algori...

memory use in large data-structures manipulation/processing

I have a number of large (~100 Mb) files which I'm regularly processing. While I'm trying to delete unneeded data structures during processing, memory consumption is a bit too high. so, I was wondering is there a way to 'efficiently' manipulate large data, e.g.: def read(self, filename): fc = read_100_mb_file(filename) self.proc...

Does C++ deep-initialize class members?

I have a class in C++ with the following member: map< someEnum, vector<SomeObject*>* > someMap So I have a map that gives me a vector of objects for each enumeration I have. For the life of me, I cannot understand how C++ is initializing these objects. Does it deep initialize them by default? If not, what do I need to do? I'm getting...

Total number of nodes in a tree data structure?

I have a tree data structure that is L levels deep each node has about N nodes. I want to work-out the total number of nodes in the tree. To do this (I think) I need to know what percentage of the nodes that will have children. What is the correct term for this ratio of leaf nodes to non-leaf nodes in N? What is the formula for working...

Debugging Datastructures Visually

I've got some Java code which builds a data structure (approx 500 small interlinked objects) from data in some files and I'd really like to visualise the resulting structure. I hope that seeing it will allow me to optimise, not the code, but the data itself. I'm wondering if there is a debugger that will do this or perhaps a way I can d...

How can I do efficient range searching + counting with latitude/longitude data?

I'm working with a large set of points represented by latitude/longitude pairs (the points are not necessarily unique, there could be several points in the set that are at the same location). The points are stored in a database. What I need to do is figure out a way to efficiently perform a search to get the number of points that lie wi...

Persiting a Queue to prevent out of memory error in C#

I have data structure, specifically a queue, that is growing so large as to cause an out of memory exception. This was unexpected behavior due to the relativity simple object it is holding (having a essentially one string field). Is there an easy way, or a built in .NET way, to save this collection to a file on disk (there is no databa...

How to store a hash table in a file?

How can I store a hash table with separate chaining in a file on disk? Generating the data stored in the hash table at runtime is expensive, it would be faster to just load the HT from disk...if only I can figure out how to do it. Edit: The lookups are done with the HT loaded in memory. I need to find a way to store the hashtable (in m...

Data structure used for implementing spreadsheets

What is the data structure used by spreadsheets program like ms-excel? ...

Need disk based priority queue library, preferably for C

I have a queuing mechanism in C on Unix. It accepts XML transactions. Some transactions contain records to be stored. Other transactions request those transactions. The transactions get stored in a file, which is a home-grown queue. First in, first out, very simple. Header area at start of file, keeps track of next position to read from,...

Which data structure uses more memory?

Which type of data structure uses more memory? Hashtable Hashmap ArrayList Could you please give me a brief explanation which one is less prone to memory leakage? ...

What is the best data structure for representing nodes in 3D space?

Hello! ... and thanks for reading... I'm still learning the ropes so please be forgiving... ;-) I am writing a function that meshes a solid in space. The mesh is done by using objects of a "Node" class and each node is represented by: int id double p double r Initially I thought that a map would be the way to go: with a map I can m...