data-structures

can realloc Array, then Why use pointers?

This was an job placement interview I faced. They asked whether we can realloc Array, I told yes. Then They asked - then why we need pointers as most of the people give reason that it wastes memory space. I could not able to give satisfactory answer. If any body can give any satisfactory answer, I'll be obliged. Please mention any situat...

Data structure for non-overlapping ranges within a single dimension

I need a data structure that can store non-overlapping ranges within a single dimension. The entire range of the dimension need not be completely covered. An example would be a conference room scheduler. The dimension is time. No two schedules may overlap. The conference room isn't always scheduled. In other words, for a given time ther...

Storing C# data structure into a SQL database

I am new to the world of ASP.NET and SQL server, so please pardon my ignorance ... If I have a data structure in C# (for e.g. let's just say, a vector that stores some strings), is it possible to store the contents of the vector as is in SQL table? I want to do this so that it fast to convert that data back into vector form as fast as p...

How can I create a repeatable signature of a data structure?

I have a situation where I want to create a signature of a data structure: my $signature = ds_to_sig( { foo => 'bar', baz => 'bundy', boing => undef, number => 1_234_567, } ); The aim should be that if the data structure changes then so should the signature. Is there an established way to do this? ...

Is there a Entity Attribute Value (EAV) framework out there for PHP/MySQL?

Is there a Entity Attribute Value framework out there for PHP/MySQL? I'm starting to write my own, but I feel like its been done already. Any suggestions? ...

How is Wikipedia's example of an unbalanced AVL tree really unbalanced?

The image above is from "Wikipedia's entry on AVL trees" which Wikipedia indicates is unbalanced. How is this tree not balanced already? Here's a quote from the article: The balance factor of a node is the height of its right subtree minus the height of its left subtree and a node with balance factor 1, 0, or -1 is considered bala...

Skip Lists -- ever used them?

I'm wondering whether anyone here has ever used a skip list. It looks to have roughly the same advantages as a balanced binary tree, but is simpler to implement. If you have, did you write your own, or use a pre-written library (and if so, what was its name)? ...

Spatial Data Structures for moving objects?

I was wondering what is the best data structure to deal with a lot of moving objects(spheres, triangles, boxes, points, etc)? I'm trying to answer two questions, Nearest Neighbor and Collsion detection. I do realize that traditionally, data structures like R trees are used for nearest neighbor queries and Oct/Kd/BSP are used for collis...

Relative performance of std::vector vs. std::list vs. std::slist?

For a simple linked list in which random access to list elements is not a requirement, are there any significant advantages (performance or otherwise) to using std::list instead of std::vector? If backwards traversal is required, would it be more efficient to use std::slist and reverse() the list prior to iterating over its elements? ...

How do I sort a CArray of a user defined type?

Is there a built-in way to sort a CArray in C++? ...

How Do I Choose Between a Hash Table and a Trie (Prefix Tree)?

So if I have to choose between a hash table or a prefix tree what are the discriminating factors that would lead me to choose one over the other. From my own naive point of view it seems as though using a trie has some extra overhead since it isn't stored as an array but that in terms of run time (assuming the longest key is the longest ...

Flexible array members in C - bad?

I recently read that using flexible array members in C was poor software engineering practice. However, that statement was not backed by any argument. Is this an accepted fact? (Flexible array members are a C feature introduced in C99 whereby one can declare the last element to be an array of unspecified size. For example: ) struct hea...

Pattern name for flippable data structure?

I'm trying to think of a naming convention that accurately conveys what's going on within a class I'm designing. On a secondary note, I'm trying to decide between two almost-equivalent user APIs. Here's the situation: I'm building a scientific application, where one of the central data structures has three phases: 1) accumulation, 2) a...

Should I use enum or query a table in my database?

In my database I have tables that define types for example Table: Publication Types ID | Type ---------- 1 | Article 2 | Abstract 3 | Book .... Which is related through the ID key to a publication tables which has the field TypeID. I then create a PublicationTable data table my .NET application which I want to filter based on ...

KDTree Implementation in Java

I'm looking for a KDTree implementation in Java. I've done a google search and the results seem pretty haphazard. There are actually lots of results, but they're mostly just little one-off implementations, and I'd rather find something with a little more "production value". Something like apache collections or the excellent C5 collection...

How to be good in Data Structures and Analysis?

I want to be good in Data Structures and Analysis esp. in Java. I often find myself very weak. What should I do to be good in it? Any good mental exercises? ...

What is the best way to pass data between a MainFrame (or Main Dialog) and a Modal Dialog?

I need a modal dialog to gather some user input. I then need the same data to be consumed by the application MainFrame. Usually my Modal Dialog would have a pointer to some DataType able to store what I need, and I'd be passing this object by reference from the MainFrame in order to be able to recover data once the modal dialog is clos...

Data structure used for directory structure?

Hi, I'm making a program which the user build directories (not in windows, in my app) and in these folders there are subfolders and so on; every folder must contain either folders or documents. What is the best data structure to use? Notice that the user may select a subfolder and search for documents in it and in its subfolders. And I d...

Where to get more information on Dictionary ADT and Skip List for Java?

I'm trying to go deep into Dictionary ADT and Skip List for Java. My textbook doesn't cover a lot about this and whatever it has covered is very complicated. Which is the best online site to get more information on Dictionary ADT and Skip List for Java. I'm looking for the one which talks visually and gives a lot of examples. ...

Skip List vs. Binary Tree

I recently came across the data structure known as a Skip list. They seem to have very similar behavior to a binary search tree... my question is - why would you ever want to use a skip list over a binary search tree? ...