data-structures

How to deal with .1 & .10 with MySQL & Rails

I currently have a MySQL database with a table that has a field that is typed as a decimal. Currently there are values that range from *.1 through *.9 but we now need to be able to handle the following: I need to be able to add *.10 to this field and sort it accordingly. In this use-case .10 DOES NOT equal .1! I need to be able to us...

Efficient Indexing method for a 2 by 2 matrix

If I fill numbers from 1 to 4 in a 2 by 2 matrix, there are 16 possible combinations. What I want to do is store values in an array of size 24 corresponding to each matrix. So given a 2 by 2 matrix, I want a efficient indexing method to index into the array directly.( I dont want comparing all 4 elements for each of 16 positions). Some...

Data structure for storing recurring events?

I'm looking for a data structure pattern for storing recurring events, but everything I came up with would result in a high number of special case handling or user input and data retrieval are overly complex. (I get the distinct feeling, that I haven't understand the problem domain well enough to do this.) How can I store Outlook-style ...

I was asked this in a recent interview

I was asked to stay away from HashMap or any sort of Hashing. The question went something like this - Lets say you have PRODUCT IDs of up to 20 decimals, along with Product Descriptions. Without using Maps or any sort of hashing function, what's the best/most efficient way to store/retrieve these product IDs along with their descripti...

What Software Engineering Areas should be stressed upon while Interviewing Candidate for Fulltime Software Engineering Position ?

Hi, This question is somewhat related to other posts which I found on Stackoverflow but not exactly and so am prompted to ask about it. I know we must ask for Data-Structures and Algorithms but what specific data-structures or Algorithms or other CS Concepts should be asked while interviewing Sr. Software Engineering Fulltime Positio...

Data structures for real time applications

We are designing a p2p applications using c++ which transmits voice to other peer using UDP. We are capturing a mic signal in a buffer in the thread which captures voice for one second in the while loop. For every second voice captured in buffer it splits it into packets and sends to the other peer. Now I need a proper data structure a...

Equivalent of C# ObservableCollection in Java

Hi, I was wondering if there is a data structure that acts like an OberservableCollection almost like in C# that is able to take a certain type. ex: In C# i am able to say.. ObservableCollection<Beer> Beer = new ObservableCollection<Beer>(); Beer.add("Bud"); <br> Beer.add("Coors"); Assuming that the class Beer is made and we can...

Biological Taxonomy Data Model

Looking for industry/standard data model for biological classification. Wikipedia ...

Prove that binary trees with the same inorder and preorder traversals are identical?

Does anybody know how to prove that if two binary trees have the same inorder and preorder traversals, then they are identical? (perhaps by showing that you can't have two different binary trees with identical inorder and preorder traversals) Alternatively, show a case that would disprove this, or show why can't it be done? (I'll admit...

Data structure for search engine in JAVA?

Hi, I m MCS 2nd year student.I m doing a project in Java in which I have different images. For storing description of say IMAGE-1, I have ArrayList named IMAGE-1, similarly for IMAGE-2 ArrayList IMAGE-2 n so on..... Now I need to develop a search engine, in which i need to find a all image's whose description matches with a word ente...

comparisons of data structures, algorithms, basic computer science, online resources

Hello, I am searching for an online resource referring to data structures and algorithms. Basicaly what I am interested in, is a kind of comprehensive list of things such as: when a data structure or algorithm is used, pros and cons compared to each other, real life-problem usage, etc. I have a couple of popular books on the subject, l...

Actionscript 'Object' labeled as a real datastructure for readability

So in actionscript 3, instances of the Object class can be used an as associative array: var doNotHaveSexWith:Object = new Object(); doNotHaveSexWith['mum'] = new Person(...); doNotHaveSexWith['dad'] = new Person(...); doNotHaveSexWith['dave'] = new Person(...); Say I have some class, and one of it's members is a read only 'Object' wh...

Test Suite for a Linked List Implementation? (and/or other data structures)

For fun, I'm going to write my own implementations of common data structures like Linked List or Binary Sorted Tree. Are there any good test suites that already exist that I can use to make sure they are fully living up to their contracts? (It probably wouldn't be that hard to test them myself, but if it's already been done I don't want...

Java: Pass by reference / ListIterator.add()

Java doesn't pass variables by reference. In that case, how do data structures like ListIterator make changes to their corresponding list? Here is an example iterator I am writing: public class OdpIterator<E> implements ListIterator<E> { private OdpList<E> list; private int cursor; public OdpIterator(OdpList<E> list) { ...

Storing Large Number Of Files in File-System

I have millions of audio files, generated based on GUId (http://en.wikipedia.org/wiki/Globally%5FUnique%5FIdentifier). How can I store these files in the file-system so that I can efficiently add more files in the same file-system and can search for a particular file efficiently. Also it should be scalable in future. Files are named bas...

Data structure to hold HQL or EJB QL

We need to produce a fairly complex dynamic query builder for retrieving reports on the fly. We're scratching our heads a little on what sort of data structure would be best. It's really nothing more than holding a list of selectParts, a list of fromParts, a list of where criteria, order by, group by, that sort of thing, for persistence...

calculating a hash of a data structure?

Let's say I want to calculate a hash of a data structure, using a hash algorithm like MD5 which accepts a serial stream, for the purposes of equivalence checking. (I want to record the hash, then recalculate the hash on the same or an equivalent data structure later, and check the hashes to gauge equivalence with high probability.) Are ...

Data structure for quick time interval look up.

I have a set of time intervals In = (an, bn). I need to run lots of look ups where I'm given a time t and need to quickly return the intervals that contain t, e.g., those intervals such that an <= t <= bn. What is a good data structure or algorithm for this? If it matters, in my case the an and bn are integers. ...

Client Access to SQL Server over the Internet

Does anyone have any opinions over the best ways to connect a client to SQL Server to get data. So lets say I have a C# DataGridView in a Winform not on the internal network and I need to load it with a lot of data. Currently to access the data we call a component SQLDataAdapter in the client which opens a connection to the SQL server,...

Circular buffer in JavaScript

I was wondering whether anyone has already implemented a circular buffer in JavaScript? How would you do that without having pointers? ...