This question is about a data structure I thought of. It is a dynamic array, like std::vector<> in C++, except the removal algorithm is different.
In a normal dynamic array, when an element is removed, all the remaining elements must be shifted down, which is O(n), unless it's the last element, which will be O(1).
In this one, if any e...
I have a streaming input which has repeated values. I can use any data structure but I have to count the number of occurence of each element. Suppose I have a list of mobile phone suppliers like the following:
Apple
Nokia
Samsung
Apple
LG
Nokia
HTC
Android
Apple
Nokia
Nokia
Apple
Samsung
I have to build any data structure preferably ...
I have used linq to entities to basically create an anonymous type with properties
bookId and rating which I have grouped by bookId. all I need to do is take this and
form an anonymous type which groups by bookId and gives the average rating for this bookid
so anonymous type results currently looklike:
bookid = 1, rating = 2
bookid...
I need to solve a problem within job booking software and am hoping to find a good way of doing that.
The current system uses a set of check boxes to represent the problem description when a customer rings up. These check boxes are useful to admin, but not really from a customer perspective.
My thoughts were to have 1 or more english r...
I have this code in my cfm, which works
<cfif not StructIsEmpty(form)>
<cfset larray = user.getArray() />
<cfloop collection="#form#" item="key">
<cfif left(key,4) eq "UPD_">
<cfset x = listLast(key,"_") />
<cfset y = evaluate(0,key) />
<cfloop index="j" from="1" to="#arrayLen(larray)#">
<cfif (larray[j][1] eq x) and (l...
I'm wondering what kind(s) of data structures / algorithms might help facilitate handling the following situation; I'm not sure if I need a single FIFO, or a priority queue, or multiple FIFOs.
I have N objects that must proceed through a predefined workflow. Each object must complete step 1, then step 2, then step 3, then step 4, etc. E...
I have data represented in CF as an array of structs e.g.:
var foo = [{key = 'bar', value = 'baz', ... }...];
This structure gets iterated over sequentially and then translated to another related struct which looks like:
foo2[key] = {key = 'bar', value = 'baz', ...};
This is then sent to the SerializeJSON() method and sent to the b...
What's the most efficient way to sort objects in an NSSet/NSMutableSet based on a property of the objects in the set? Right now the way I am doing it is by iterating through each object, add them to a NSMutableArray, and sort that array with NSSortDescriptor.
...
Unfortunately Sun Microsystems behaving badly by removing the link to the article on how to create custom storage engine for MySQL. By any chance you have that article, or can point to another resources on the web that talks about how to create custom engine?
This is 'dead' link
...
I'm looking for the one algorithm or data structure which is so unknown yet useful that you think it's a horrible oversight by the computer science or programming community. If only we could all learn this one thing, a lot of good would be done to many future programs.
The best one I can come up with is interpolation search, which only...
I am having a lot of IDs and I want to store them for a temporary purpose and need to search that record for some operation. Which data structure is good for this operation in Perl? Should I use a hash or an array, or is there any other module I could use to do this efficiently?
The records are 4343, 34343, 34343, 2323, 232, ....
...
Once I created a form builder where user could select any number of fields for a web form. The tool then produced a code snippet which user could copy in the JSP.
The submitted form data was stored as a key-value pairs in the DB, so basically just two columns were required for the form specific data. If I remember right, the processing ...
I have a set of data and I want to find the biggest and smallest items (multiple times), what's the best way to do this?
For anyone interested in the application, I'm developing a level of detail system and I need to find the items with the biggest and smallest screen space error, obviously every time I subdivide/merge an item I have to...
I have to write kind of a complicated query to get some statistics for the rules in our system for each Agency we have in our database.
It looks something like this:
There will be an arbitrary number of columns (rules) and rows (agencies) for this data. For example, here there are 5 main rule columns shown, but this could just as eas...
Usecase maintain a list of the last n visited URLs (where n is a fix number). As new URLs are added to the list, older urls are removed automatically (in order to keep it at n elements)
Requirement The data structure needs to be sorted by time (should be no problem if it accepts a Comparator).
...
How would you invert a stack, without using extra data structures, like a second, or temporary, stack. Thus no stack1-stack2 or stack-queue-stack implementation in the answer. You just have access to push/pop feature of a standard stack.
I think there is way to do it by keeping a global counter and using pointer manipulation.
...
i have an array wich contains another array
Would i notate it this way?
pseudocode:
rgrgTest = newArray(2)
What if the array contains i.e. a struct?
pseudocode:
rggrTest = newArray(2).newStruct()
Or this way i.e. if i want to classify the data types of the struct?
pseudocode:
rggrlstlTest = newArray(2).newStruct(int id, str desc,...
Are there any HashMap implementations that expose hook methods for profiling the performance of the Map (average chain length, best / worst / average access time, #rehashes, etc.).
It seems quite common to use HashMap and "hope for the best" with regards to ~O(1) access time, without analysing whether this is really the case but I'd lik...
I often auto-generate an class's hashCode() method using IntelliJ IDEA and typically the method takes the form:
result = 31 * result + ...
My question is what is the purpose of multiplying by 31? I know this is a prime number but why pick 31 specifically? Also, if implementing a hashCode() for a particularly small / large dataset wo...
I need to document an application that serves as a facade for a set of webservices. The application accepts SOAP requests and transforms these requests into a format understandable by the underlying web service. There are several such services, each with its own interface. Some accept SOAP, some HTTP POST, some... other formats not menti...