Are there any map data structures that have at least O(log n) insertion, deletion, access, and merging?
Most self-balancing binary trees such as AVL trees and red-black trees have most of these properties, but I believe they have O(n log n) merging. Are there any data structures that have faster merging?
Edit: I have looked around, and...
I have heard of people using them for keeping track of session variables, but I really want to know if there are many uses for them and under what conditions it would be beneficial to employ a hashtable vs any other data structure that can handle key value pairs, like a dictionary for example.
eg. I have heard of people putting session ...
Given a bunch of strings I need to find those which match 3 kinds of patterns:
Prefix search - abc*
Glob-like pattern - abc:*:xyz
Suffix search - *xyz
where * is a wildcard (and can match any number of chars).
Now the straight-forward solution is just to scan every string and see if it matches the target pattern. But this is O(n). I...
I'm currently trying to implement the Index Fabric for a dna sequence data search system:
Index fabric algorithm
I could implement the normal patricia trie, but I still couldn't understand how to add layers. I also tried google but couldn't find enough information about adding layers to the patricia trie there either. In the paper me...
I want to build a data structure which is basically a matrix of strings with the following.
A growable no of rows
A FIXED no of columns
I want to be able to get at whatever is in a particular row or column via a method call that takes the an integer row no and an int col number as an argument. In addition I want to be able to set the...
I'm developing a class that will be used to generate a tree structure. Each Node of the tree needs to know both who it's parent is and who it's children are. The fields used to track each Nodes parent and children are not accessible outside the base Node class.
Right now I have methods for AddChild, and Remove child. Which consequently...
I want to do a simple versioning system but i don't have ideas on how to structure my datas, and my code.
Here is a short example:
User logs in
User has two options when uploading a file:
Submit a new file
Submit a new version of a file
Users should be able to see the tree. (the different version)
The tree can only be up to 2 leve...
I have a bunch of tables in a relational database which, obviously, are dependent upon one another due to foreign key relationships. I want to build a dependency tree, traverse it, and output INSERT SQL statements. I need to first output SQL for foreign key tables in my dependency tree first because parent tables will depend on values fr...
Hello,
I have created a single linked list. Everything works fine.
I just want to know if I have done anything potentially dangerous in my code. The code snippets I am concerned about is my push, pop, and clean-up. The parts of the code is just for user interaction so not really important (I posted anyway so that it was more clear in ...
Hello, for a project i'm currently working on, im trying to pass a set of objects all somehow linked to one object.
I'm currently blacked out and can't seem to find a proper solution.
The situation is like this. I have a product object, on which a few insurance packages apply. I need to pass this information to the view, but I have to ...
I've been developing an in-house DSP application (Java w/ hooks for Groovy/Jython/JRuby, plugins via OSGi, plenty of JNI to go around) in data flow/diagram style, similar to pure data and simulink. My current design is a push model. The user interacts with some source component causing it to push data onto the next component and so on un...
I have an array of 200 items. I would like to output the array but group the items with a common value. Similar to SQL's GROUP BY method. This should be relatively easy to do but I also need a count for the group items.
Does anyone have an efficient way of doing this? This will happen on every page load so I need it to be fast and scala...
I have the following hash:
user = {
'user' => {
'title' => {'weight' => 1, .... }
'body' => {'weight' => 4, ....}
....
....
}
}
Is is possible to get the User sorted by the weight key of its child hashes?
I looked in the Hash.sort, but it looks like it returns array rather than my original hash sorted.
...
I was looking in Generics.Collections and noticed there was no linked list. Sure they are simple to make, but I thought it was odd there was not one (or I just missed it). Are linked lists just outdated when compared to new modern data structures, or is there a need for a general generic linked list? Does anyone know of one?
...
I'm looking for Java solution but any general answer is also OK.
Vector/ArrayList is O(1) for append and retrieve, but O(n) for prepend.
LinkedList (in Java implemented as doubly-linked-list) is O(1) for append and prepend, but O(n) for retrieval.
Deque (ArrayDeque) is O(1) for everything above but cannot retrieve element at arbitrary...
This is a composed concurrent list multimap implementation. A lower-level implementation would be better, but more complex.
Ignoring the O(n) removal in the sublist, is this the correct way to compose a ConcurrentMap and CopyOnWriteArrayList into a functional ConcurrentMultimap? Are there any unresolved data races?
private final Concur...
I was curious how long a dynamic array could be so I tried
SetLength(dynArray, High(Int64));
That has a value of 9,223,372,036,854,775,807 and I figure that would be the largest number of indexes I could reference anyway. It gave me a:
ERangeError with message 'Range check error'.
So I tried:
SetLength(dynArray, MaxInt);
and...
The following code errors:
<cfdbinfo datasource="#Application.DSN#" name="getCols" type="columns" table="#this.tableName#">
<cftry>
<cfquery name="getColumnDetails" dbtype="query">
SELECT COLUMN_NAME,TYPE_NAME
FROM getCols
WHERE IS_PRIMARYKEY = 'NO'
</cfquery>
<cfcatch>
<cfset this.ErrorState = true>
<cfthrow m...
I am looking for an efficient way to detect the number of unique values in an array.
My current approach:
Quicksort array of integers
Then run a loop to compare elements.
In code:
yearHolder := '';
for I := 0 to High(yearArray) do
begin
currYear := yearArray[i];
if (yearHolder <> currYear) then
begin
yea...
I have an existing (java) application that models an order book, as it stands each order is visible to every other. There is now a requirement to put (what is effectively) a per order ACL in place.
An example to illustrate, lets say I have access groups [V-Z] and orders [A-F]
A B C D E F
V 1 0 0 1 1 0
W 0 1 1 0 0 1
X ...