algorithm

Help Identifying If Specific Problem is a Classical Comp Science Problem

Hi All, I have a manufacturing-process issue I tackled ages ago in VBA, and it's held up for some time now although it's progressively running slower and slower as more data gets into the file. I think it's finally time to rewrite a more elegant solution in a different language, outside of VBA, but am curious if anyone knows of this be...

How is the data stored in a textbox?

I was reading this paper "Ropes: an Alternative to Strings" about ropes [figure from the same paper] and I was wondering if that is the data structure used by today's browsers to implement textboxes or not. Do we use ropes or some other data structures for this? Are ropes used somewhere besides textboxes? The previous title of m...

Tokenize valid words from a long string

Suppose you have a dictionary that contains valid words. Given an input string with all spaces removed, determine whether the string is composed of valid words or not. You can assume the dictionary is a hashtable that provides O(1) lookup. Some examples: helloworld-> hello world (valid) isitniceinhere-> is it nice in here (valid) zx...

iterative closest point library

is there any c++/c open source implementation? i got two point clouds and would like to match them.. any ideas? ...

Create 2d triangles from 2d points

Hi, I have to make 2d triangles from a list of 2d points with a condition: length of any edge can't be longer than a predefined constant. Something like this: Do you know any algorithm that can do this? Or any advise? Thanks! ...

Transformation from one position scale of notation to another

How can I transform from one scale of notation to another using my custom function by C#. abstract string Convert(string value, string fromBase, string toBase); value - string representation scale of notation in basic notation fromBase - string represent the base of numeric toBase - string representation the base of numeric which y...

Dissolve string bytes into a fixed length formula based pattern by using keys, and even extract those bytes.

Suppose there is a string containing 255 characters. And there is a fixed length assume 64-128 bytes a kind of byte pattern. I want to "dissolve" that string with 255 characters, byte by byte into the other fixed length byte pattern. The byte pattern is like a formula based "hash" or something similar into which a formula based algorithm...

Is this a known DES cipher? What DES cipher is it? DES-CTR?

import Crypto.Cipher.DES import struct def rol32(x, y): ret = ((x<<y)&0xFFFFFFFF)|((x>>(32-y))&0xFFFFFFFF) #print 'rol32', hex(x), hex(y), hex(ret) return ret def sub32(x, y): ret = (x & 0xFFFFFFFF) - (y & 0xFFFFFFFF) if ret < 0: ret += 0x100000000 #print 'sub32', hex(x), hex(y), hex(ret) return ret def mul32...

What are some methods of dynamic validation for a generic class?

So basically the title sounds way fancier than the actual question. I am writing an application in which I would like to implement an achievement system. If I have all of my achievements created as instances of a generic class, how do I write a method to validate those achievements (i.e. determine if the user has met or exceeded goals) ...

Password protected website with JavaScript

I have a quetion which may be simple/dumb or not :). In other words I have no idea if is fair enough or a completely foolish idea. Just some free thoughts. What if I make my login via JavaScript with pass in it (yes I know), but pass will be hased by Secure Hash Algorithm. For instance: I generate a pass with SHA which looks like var...

Algorithm for issuance of delivery

I need to get inherited class of DispenseAlgorithm. It must realize algorithm for calculate issuance of delivery. The algorithm must provide even nominals consumption . public abstract class DispenseAlgorithm { public abstract Dictionary<int, int> CalculateDispense(CassetteData[] data, int summ); } public class CassetteData { ...

Algorithm to visit all points in a matrix of N (unknown) dimensions.

I have a multidimensional matrix that can have any number of dimensions greater than one. Looking for an efficient algorithm that can visit every point in the matrix. Some info about the code: The matrix has value accessors like (although these aren't really relevant). object value = matrixInstance.GetValue(int[] point); matrixInsta...

efficient algorithm for searching one of several strings in a text?

I need to search incoming not-very-long pieces of text for occurrences of given strings. The strings are constant for the whole session and are not many (~10). Additional simplification is that none of the strings is contained in any other. I am currently using boost regex matching with str1 | str2 | .... The performance of this task is...

Finding duplicates within list of list

Simple situation. I have a list of lists, almost table like, and I am trying to find out if any of the lists are duplicated. Example: List<List<int>> list = new List<List<int>>(){ new List<int>() {0 ,1 ,2, 3, 4, 5, 6 }, new List<int>() {0 ,1 ,2, 3, 4, 5, 6 }, new List<int>() {0 ,1 ,4, 2, 4, 5, 6 }, new List<int>() {0 ,3 ,2, 5,...

probability bound on number of collisions in a hash table

I'd like to get a probability bound on the maximum number of collisions in a hash table. I.e., given number of buckets m, number of items n, what is: Prob(number of collisions < c) as a function of n, m and c, where c is some number between 1 and n. For example, c=1 would be the birthday paradox (~e^(-n^2/2m)) and c=n would be 1. (I...

problem with merge sort

void merge(vector<int> dst,vector<int> first,vector<int> second) { int i=0,j=0; while(i<first.size()&&j<second.size()) { if(first[i]<second[j]) { dst.push_back(first[i]); i++; } else { dst.push_back(second[j]); j++; } } wh...

java get duration from database

table structure: sysdurationtimeday , sysdurationtimehour, sysdurationtimeminute 1, 12,10 3, 23,10 0, 0,10 i have these 3 fields from database, after getting these 3 values, what is the technique that i can use do cast to which Java Object? (maybe Calendar.class, TimeStamp.class) ? and use it to compared with record is spent less th...

How to display unique numbers with their frequencies as occurring in a matrix?

Hi . I have a matrice with some number: 1 2 3 6 6 7 2 1 1 4 5 6 And the program should display all different number with own frequency for example: 1 -> 3 2 -> 2 3 -> 1 4 -> 1 5 -> 1 6 -> 3 7 -> 1 Please help me ...

Best approach: transfer daily values from one year to another

I will try to explain what I want to accomplish. I am looking for an algorithm or approach, not the actual implementation in my specific system. I have a table with actuals (incoming customer requests) on a daily basis. These actuals need to be "copied" into the next year, where they will be used as a basis for planning the amount of ...

Why does java.util.Arrays.sort(Object[]) use 2 kinds of sorting algorithms?

I found that java.util.Arrays.sort(Object[]) use 2 kinds of sorting algorithms(in JDK 1.6). pseudocode: if(array.length<7) insertionSort(array); else mergeSort(array); Why does it need 2 kinds of sorting here? for efficiency? ...