data-structures

Dynamic table / matrix data structure for Java

I need a Java implementation of table-like data structure where I could dynamically insert or delete rows and columns. I need to get data from any row or column very fast and with no overhead in selecting row over column or vice versa. Does anyone know libraries where such data structure is already implemented? ...

Need help in returning from a recursive method

Hi, I am trying to trace the path of a node in a binary tree (not a binary search tree). Given a node, I am trying to print the values of the path from the root. I have written the following program. package dsa.tree; import java.util.Stack; public class TracePath { private Node n1; public static void main(String args[])...

Associative Matrices?

I'm working on a project where I need to store a matrix of numbers indexed by two string keys. The matrix is not jagged, i.e. if a column key exists for any row then it should exist for all rows. Similarly, if a row key exists for any column then it should exist for all columns. The obvious way to express this is with an associative a...

Data model refactoring for Rails-based fundraising event registration/pledging site

I'm re-factoring a semi-successful Rails-based event registration and pledging system for a particular fundraising event for a non-profit. The existing data structure is rather ungainly, though it captures all necessary details and relationships. I would plan to refactor this in any case, but since I've also been asked to allow for mul...

I want to develop a application for CRM in C#

I need some project that I can read it's source code and learn the design structure from it.This project should have a database layer, and business rule layer, anyone has suggestions? Thanks in advance ! ...

Explanation of how stacks work in C

I am just wanting a simple explanation of the linking process when pushing data onto a stack. I know how to build on using the code from my book, but I am not really sure I understand how the process works when you move the stack head link from one to the next. For stacks like: typedef struct node { void dataptr; struct node* l...

Is there a C++ MinMax Heap implementation?

I'm looking for algorithms like ones in the stl (push_heap, pop_heap, make_heap) except with the ability to pop both the minimum and maximum value efficiently. AKA double ended priority queue. As described here. Any clean implementation of a double ended priority queue would also be of interest as an alternative, however this question ...

Is there a way to do more "dynamic" data constructors in Haskell?

Is there some Haskell extension that enables the creation of more complex data constructors then GADT? Suppose I wanted to create a data structure that is an ordered list, and have a data constructor similar to (:) that work with lists, with type signature: data MyOrdList a where (>>>) :: (Ord a) -> a -> MyOrdList a -> MyOrdList a ...

Ideas for specific data structure in c++

I need to do some task. There are numbers give in two rows and they act like pairs of integers (a, b). I have to find the maximum 5 numbers of the a-row and then select the max of those 5 but this time from the b-row. Ex: 1 4 5 2 3 3 7 5 6 6 2 9 3 1 In this example, the pair i need is (6,6) because 6 (a) is in the top 5 of the a[i] nu...

Options for read-only binary flat-file storage using Python

I have been tasked with setting up a flat-file SKU database for use on embedded devices with limited storage and processor speed. Basically the data I need to store consists of the following: SKU Description Location Price Qty The file will consist of several million records. The most important considerations are storage space and re...

What operations can be performed on disjoint sets?

I just studied the disjoint set data structure and I know that it is also called "union-find data structures", union and find are two main operations of this data structure. We can can perform union on disjoint sets, similarly we can perform find operations; I want to know what other operations we can perform on disjoint sets except unio...

Searching from a stack

I am implementing a stack and while it was a no-brainer to implement the basic operations push and pop, I am wondering how to implement somewhat efficient searching. The underlying structure is a linked list ...

Binary tree to get minimum element in O(1)

I'm accessing the minimum element of a binary tree lots of times. What implementations allow me to access the minimum element in constant time, rather than O(log n)? ...

Error with my program

Okay I have the queue program that I have been working on and I finally figured most of it out. The problem I am having now is that everytime I enter numbers into the keyboard and then access them I get the same number. if I enter 5 ones when it goes to add them together it says the answer is 37 which is not right. here is my code again:...

Implementing a "Partial Date" object

We have a requirement for a "Partial Date" object which would allow you to specify dates such as new PartialDate(1, null, null); // first of the month new PartialDate(1, 2, null); // first of the February new PartialDate(null, 2, null); // February The use case is in relation to events. For example, you might have a course whic...

Why use an array to implement a "list" instead of a hash table?

Consider an array versus a hashtable where the keys are just the integral indexes of a list. Their average-case insertion, lookup, and removal big-O bounds are all O(1) constant time. I understand that you may get some low-level wins in cache locality with an array, and there is a marginal (mostly-constant) overhead to the hashtable ope...

Calculating number of messages per second in a rolling window?

I have messages coming into my program with millisecond resolution (anywhere from zero to a couple hundred messages a millisecond). I'd like to do some analysis. Specifically, I want to maintain multiple rolling windows of the message counts, updated as messages come in. For example, # of messages in last second # of messages in last ...

Disjoint Set ADT Implementation in c++

Hay Dear! I have problem in implementing disjoint set ADT in c++ due to the fact that our teacher only explained the union and find operations. I have full concept of union and find but still I am confused about how to implement. Please give me an idea , also explain what should be the interface of this data structure. Explain this data...

Grouping related search keywords

I have a log file containing search queries entered into my site's search engine. I'd like to "group" related search queries together for a report. I'm using Python for most of my webapp - so the solution can either be Python based or I can load the strings into Postgres if it is easier to do this with SQL. Example data: dog food goo...

Way to store a large dictionary with low memory footprint + fast lookups (on Android)

I'm developing an android word game app that needs a large (~250,000 word dictionary) available. I need: reasonably fast look ups e.g. constant time preferable, need to do maybe 200 lookups a second on occasion to solve a word puzzle and maybe 20 lookups within 0.2 second more often to check words the user just spelled. EDIT: Lookups...