algorithm

I need CRC Reverse Code for my CRC64 Checksum Coding

Can someone please code me the CRC64 Reverse Algorithm in C#? I am unable to code it, can't understand anything. Thanks, I have copied the CRC64 Checksum code from C++ and converted it into C# .NET. The entire code is displayed below: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CRC64...

Need help with this programming problem involving flipping coins

Hello, Im trying to solve the flipping coins problem on codechef.com (http://www.codechef.com/problems/FLIPCOIN/) My code is in C, and i tested it using gcc v4.4.3 on my machine running Linux,and my program works for the sample input provided. However, on uploading to the judge i get the message "Wrong Answer". In my program i represent...

Algorithm for number of transitions between pair of set (graph) partitions

Say I have a set (or graph) which is partitioned into groups. I am interested to find the number of transitions between two partitions, where a transition involves taking an element out of one partition and moving it into another (or singleton partition by itself) For example there is one transition between partitions 1 2 | 3 and 1 |...

Algorithm for footnote layout with columns

I have implemented a basic page layout algorithm for footnote placement. Basically: Layout a line of body text. If it contains footnote references, lay out footnotes line by line. Go to 1. At every step, I check to see if the total height (body text + footnote text + gap) exceeds page height. If it does, I remove the most recently l...

Cycling LED Modes using ControllerMate

I'm using ControllerMate with a Nostromo (Belkin) n52 (NOT the te version) Speedpad on an iMac running Snow Leopard. The official SpeedPad configuration software doesn't run beyond Tiger, or at least, it doesn't run on Snow Leopard due to the kext failing to load properly, hence the attempt at using ControllerMate. The official SpeedPa...

Lowest Common Ancestor of Binary Tree(Not Binary Search Tree)..

I tried working out the problem using Tarjan's Algorithm and one algorithm from the website: http://discuss.techinterview.org/default.asp?interview.11.532716.6, but none is clear. Maybe my recursion concepts are not build up properly. Please give small demonstration to explain the above two examples. I have an idea of Union Find data-str...

N-Puzzle with 5x5 grid, theory question

I'm writing a program which solves a 24-puzzle (5x5 grid) using two heuristic. The first uses how many blocks the incorrect place and the second uses the Manhattan distance between the blocks current place and desired place. I have different functions in the program which use each heuristic with an A* and a greedy search and compares th...

Linked List of Intervals

Hello I have the following two questions. I'm aware of the concept of a linked list. What is a linked list of intervals? I need to store a very huge (more than 100 bits) number in C/C++ and perform bitwise operations on it. Without using any big number library, what would be the best data structure to handle this scenario ? Thank Yo...

Independent set in a graph

As you know finding maximum independent set is NP. Is there an algorithm to find out whether a given graph has an Independent set of at least k vertices? Note that we don't want to find it. We just want to find out if such thing exists. ...

data structure to speed in-memory tagged object search on boolean function of tags?

If I have a set of tags (<100), and a set of objects (~25000), where each object has some sub-set of the tags, do you know of an existing data-structure that would allow for fast retrieval of those objects that satisfy some boolean function of the tags? Addition/deletion of tags and objects need not be particularly fast, but selection o...

Primefactors in F#

I am trying to learn F#. I wrote a function that factors out primes. let PrimeFactors x = let rec PrimeFactorsRecursive x div list = if x % div = 0 then PrimeFactorsRecursive (x/div) div list @ [div] elif div > int(System.Math.Sqrt(float(x))) then if x > 1 then list @ [x] else list else PrimeFactorsRecur...

How to reverse this algorithm to get back the original text?

Can anyone please explain with the easy coding how to reverse this algorithm so that I get back the original text string? Public Function CreateIntChecksum(ByVal s As String) As Integer Dim r As Integer = 0 For i As Integer = 0 To (s.Length() - 1) Dim bchar As Byte = Convert.ToByte(s(i)) r = bchar + ((r << 5) - r...

Reversible shuffle algorithm using a key

How would I code a reversible shuffle algorithm in C# which uses a key to shuffle and can be reversed to the original state? For instance, I have a string: "Hello world", how can I shuffle it so that later I could be able to reverse the shuffled string back to "Hello world". ...

Undo/Redo implementation

Give me some thoughts how to implement undo/redo functionality - like we have in text editors. What algorithms should I use and what I may read. thanks. ...

What Mathematical Technique is used to compare algorithm complexity?

Hi all I started reading 'Introduction to Algorithms' today, but I've gotten a bit confused over one of the exercises. Exercise 1.2.2 asks the reader Suppose we are comparing implementations of Merge sort and Insertion Sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in...

Binary Array Compression in C

I have binary array in c, I want to compress the array, kindly suggest me algorithm which compress binary array. I have used Lempel–Ziv–Welch (LZW) algorithm but its not suitable for me because there is no repetition in my data. ...

Algorithm that is a combination of the continuous knapsack problem and the variable size bin packing problem

Hello, I'm trying to solve a problem (in php, but programming language doesn't matter). I'm having a n number of persons that have paid money, and I have got a m number of persons that are going to pay the same amount as the sum of what the n number of people have paid. I want to calculate the shortest route of money transfers between th...

Simple 1-D particle swarm optimization algorithm for a noisy environment

I'm experimenting with particle swarm optimisation and am trying to determine the best approach for the following simple scenario: Optimizing a 1-dimensional function (i.e. particles are moving along a single line) The function to be optimised can be sampled at any point on the line The "value" sampled for each position is very noisy T...

How does a 32-bit operating system perform the 2^56 modulo 7 ?

How does the system perform the 2^56 modulo 7, if it's 32 bits operating system in cryptography for example? And how it stored in memory? ...

What are the practical applications of the lowest common ancestor algorithms?

I was having a look at this question and then reading about Tarjan's least common ancestors algorithm. I never came across any applications of LCA algorithms before. Where are such LCA algorithms commonly used? ...