algorithm

Is Terra Compression possible? If so, please explain and provide samples.

Long Ascii String Text may or may not be crushed and compressed into hash kind of ascii "checksum" by using sophisticated mathematical formula/algo. Just like air which can be compressed. To compress megabytes of ascii text into a 128 or so bytes, by shuffling, then mixing new "patterns" of single "bytes" turn by turn from the first to t...

Shortest path on a graph where distances change dynamically? (maximum energy path)

I'm trying to find the shortest path between two maxima on a discrete energy landscape whereby the shortest path is that which reduces the least in height over the course of the total path. Probably maximum energy path is more correct terminology, but in other words even if a path travels a long distance around the landscape but does no...

Counting unique words in a file? Good Linear Search alternative?

I'm using a naive approach to this problem, I'm putting the words in a linked list and just making a linear search into it. But it's taking too much time in large files. I was thinking in use a Binary Search Tree but I don't know if it works good with strings. Also heard of Skip Lists, didn't really learn it yet. And also I have to use...

Grid data structure

Usually ‘expandable’ grids are represented as list of lists (list of rows, each row has list of cells) and those lists are some kind of linked lists. Manipulating (removing, inserting) rows in this data structure is easy and inexpensive, it’s just matter of re-linking previous nodes, but when it comes to columns, for instance removing...

What is the real name of median sort and/or where can I find more material on it.

I'm reading the book Algorithms in a Nutshell published by O'Reilly Media and I was reading the section on sorting algorithms and found one called Median Sort. Since I had never heard of it before and my textbook from CS3 (which covered algorithms) did not have it listed, I googled it and tried looking it up on Wikipedia and found nothin...

Looking for a model to represent this problem, which I suspect may be NP-complete.

(I've changed the details of this question to avoid NDA issues. I'm aware that if taken literally, there are better ways to run this theoretical company.) There is a group of warehouses, each of which are capable of storing and distributing 200 different products, out of a possible 1000 total products that Company A manufactures. Each w...

I need an optimal algorithm to find the largest divisor of a number N. Preferably in C++ or C#

I am currently using the following code but its very slow for large numbers static int divisor(int number) { int i; for (i = number / 2; i >= 1; i--) { if (number % i == 0) { break; } } return...

Rotating 64 CCSprites more efficiently?

I have an 8 by 8 matrix of sprites that I need to be able to rotate all of them 90 degrees at once. The way I've done it is using nested for loops, and a 2 dimensional array of sprite pointers. for(row = 0;row<9;row++){ for(column = 0;column<8;column++){ [trolls[row][column] runAction:[RotateBy actionWithDuration:0.01 an...

Where to find what O(n^2) and O(n) etc means?

I've been noticing answers on stack overflow that use terms like these, but I don't know what they mean. What are they called and is there a good resource that can explain them in simple terms? ...

Array combinations of 0s and 1s

What is a good algorithm to fill an array with 0s and 1s combinations. For example if I have three columns the combinations would be: (1 1 1) (0 1 1) (1 0 1) (0 0 1) (1 1 0) (0 1 0) (1 0 0) (0 0 0) It makes a total of 8 rows (I hope I'm right here). So how to determine the needed number of rows in advance (depending on the N num...

Learning AI by practice ( Perceptrons, Neural networks and Bayesian AI)

I'm about to take a course in AI and I want to practice before. I'm using a book to learn the theory, but resources and concrete examples in any language to help with the practice would be amazing. Can anyone recommend me good sites or books with plenty of examples and tutorials ? Thanks ! Edit: My course will deal with Perceptrons, N...

Does anyone have CRC128 and CRC256 Code in C++ and C#?

I am learning, trying to get thoughts behind CRC. I can't find CRC128 and CRC256 code anywhere. If anyone of you have the C++ or C# Code for them, please share them with me. Also provide online links to the websites. I am a newbie and can't code it by myself at all, neither can convert theories and mathematics to the coding. So I ask for...

overlapping segments

Hi, i have a huge list of two-element tuples which are coordinates of segments (start, end). In this way in a list below list = [ (1,4), (2, 3), (10, 20), (18, 45) ] there are 4 segments with their start and end localization. I would like to remove segments that overlap. I expect to have a list like this as a result: list = [ (1,4...

Any way to use multiple encryptions on one string without doubling or expanding the size of the output string?

My input string suppose is: 256 Bytes Ascii text. Let's assume I encrypted it with an encryption algo. But when I re-encrypt the same encrypted result string which was output of the first encryption, the size of the second result string from the second encryption from the same encryption algo increases, even doubles! Dear friends! Is th...

Best data structure to store one million values?

Please mention time complexity and best data structure to store these values, when values are: Integers Strings (dictionary like sorting) I know Counting sort is preferred when integers are in a small range. Thanks. Edit: Sorry, I asked a bit different question. Actual question is what would be the best data structure to store the...

Java: Good algorithm for removing an element from a linked list?

I have a pretty basic question here. I am implementing a few operations on a linked list as an exercise. One such operation is removal: /** * Removes the element at index. * @param index * @throws IndexOutOfBoundsException If index is greater than the list's length. */ public void remove(int index) throws IndexOutOfBoundsExceptio...

Algorithm for determining if strided arrays overlap?

In the library I'm working on, we have data sets (which may be subsets of other data sets) that are distributed in memory in three-dimensional rectangular strided arrays. That is, an array A can be subscripted as A(i,j,k), where each index ranges from zero to some upper bound, and the location of each element in memory is given by: A(i...

PHP: Help with creating algorithim for File system structure for auto-incrememted images

I have nearly 1 million photos auto-incrememted starting at "1". So, I have the following: 1.jpg 2.jpg 3.jpg 4.jpg 5.jpg .... 1000000.jpg Currently, I have all of these files in a single Ext4 linux directory. As you can imagine, the filesystem is crazy slow. Using PHP, how can I create an algorithm that divides up my images into a ...

What's a good set of heuristics for threading tweets?

Everyone knows, if you want to thread emails you use Jamie Zawinski's alogirhtm. But it's a new century, and there's a new messaging service. What's the best algorithm for threading status updates posted on twitter? Things I'd definitely like it to cope with: Understanding in_reply_to_status_id Understanding in_reply_to_user_id, and ...

editing a line in a text file without using pointers?

Could some one help me out in editing a line of a text file(.Hex file) containing all Hex characters without using pointers and in a more efficient way? It takes so long because the program I have to edit some (around 30x4 bytes or 30 float values from the address values of hex file). Every time the program replaces one byte, it sear...