algorithm

Latex algorithm. Can't get it to work.

Hi, Im trying to write an algorithm using the algorithm package, but when I use any keyword (if, while, state, etc) it won't compile Here's what I type in (snippet) \documentclass[9pt]{article} \usepackage{algorithm} \begin{document} \begin{algorithm} \caption{Calculate $A_{nxn}$} \label{Algorithm 1} \IF{$n<0$} \STATE $x \leftarrow ...

Brute force Algorithm for creation of Sudoku Board

What I am developing is that initially the entire sudoku board is empty. One of the random cells(out of 81) is filled with a random value(1-9). Now I want to fill all the remaining cells using brute force approach. From what I came to know after googling is that we should start with the first cell and fill it with 1(if it's valid), th...

Level order traversal

void traverse(Node* root) { queue<Node*> q; Node* temp_node= root; while(temp_node) { cout<<temp_node->value<<endl; if(temp_node->left) q.push(temp_node->left); if(temp_node->right) q.push(temp_node->right); if(!q.empty()) { temp_node = q.fro...

Find a root of a polynomial modulo 2^r

I have a polynomial P and I would like to find y such that P(y) = 0 modulo 2^r. I have tried something along the lines of Hensel lifting, but I don't know if this could even work, because of the usual condition f'(y mod 2) != 0 mod 2 which is not usually true. Is there a different algorithm available ? Or could a variation of Hensel li...

how to cluster evolving data streams

Hi Guys, I want to incrementally cluster text documents reading them as data streams but there seems to be a problem. Most of the term weighting options are based on vector space model using TF-IDF as the weight of a feature. However, in our case IDF of an existing attribute changes with every new data point and hence previous clusterin...

Multiple Image Placement Algorithm - Collage Algorithm

I'm creating an application to display multiple videos concurrently (lets say 2-10 videos). I'm basically looking for an algorithm which can aid in the placement of the videos on the screen. The problem I face is that each video may have a different aspect ratio, and I will obviously need to resize the videos to make them all fit on the ...

Minimum window width in string x that contains all characters in string y

Find minimum window width in string x that contains all characters in string y. E.g. String x = "coobdafceeaxab" String y = "abc" Answer should be 5 because the shortest substring in x that contains all three letters in y is "bdafc". I can think of a naive solution with complexity n^2 * log(m), say n = len(x) and m = len(y). Can any...

difference between back tracking and Dynamic programming

Hi, I heard the only difference between dynamic programming and back tracking is DP allows overlapping of sub problems. (fib(n) = fib(n-1)+ fib (n-2)). Is it right ? Are there any other differences ? Also I would like know some common problems solved using these techniques. ...

Which is faster obj instanceof class or obj.booleanAnyMethod()

I was asked this in an interview. Not counting the time it takes to execute the method body. Any ideas? ...

Link weight between DBpedia objects

Hi guys, I am bit new to this semantic web topic and especially DBpedia, as much as I did reading about this I could not find any information about possibility to determine weight of link between DBpedia objects. For example, is it possible to determine that PHP is more related to Symfony than Ruby on Rails is, even though they are both...

Algorithms to play Game of Go ?

What is the state of the art of algorithms to play the game of Go ? Which articles (describing algorithms) are best to read ? There is a StackExachge site devoted to Go, but not enough people commited to ask the question there. ...

data for testing graph alogrithms

Hi, i am looking for a source of huge data sets to test some graph algrothm implemention. The files should be in an easy to read file format somthing like: $Node1 Node23 Node322334 Node43432 $Node2: Node232 ... Thanks, Chris ...

How to solve my difficulty making algorithms?

First of all, sorry, but my English is not very good. I'm at the third semester at a programming course and I can't "get it". I passed previous exams because I've studied three times the amount my colleagues did. And, now in my Data Structures class when the professor asks us to make list algorithms ( for example ), my colleagues just...

How to draw a tree structure? (A two-dimensional space allocation tree recursion algorithm?)

I have an arbitrary tree structure of nodes. I want to draw this tree to provide users a visual representation. I need to recurse over the tree and for each node add a graphic item to a list, and then just draw the list of items once tree recursion has finished. The recursion and drawing of items is of course trivial - what's a bit more ...

Linear Search Algorithm Optimization

I just finished a homework problem for Computer Science 1 (yes, it's homework, but hear me out!). Now, the assignment is 100% complete and working, so I don't need help on it. My question involves the efficiency of an algorithm I'm using (we aren't graded on algorithmic efficiency yet, I'm just really curious). The function I'm about to...

What shuffling algorithms exist besides Fisher-Yates and finding the "next permutation?"

Specifically in the domain of one-dimensional sets of items of the same type, such as a vector of integers. Say, for example, you had a vector of size 32,768 containing the sorted integers 0 through 32,767. What I mean by "next permutation" is performing the next permutation in a lexical ordering system. Wikipedia lists two (http://en...

How to factor a number functionally

For example, if the input is 825 the output expected is (0 1 2 0 1). What this means is: 0 two's, 1 three's, 2 five's, 0 seven's and 1 eleven. Doing this imperatively was quite easy for me. Functional, not so much. Could you please guide me how to go about solving the above problem in a functional way? Note: Fold/reduce ways will be pr...

Utility to compress jpeg as good as photoshop or better

Photoshop has a very good jpeg compression algorithm, using which it creates smaller files with same visual quality (compared to for example ImageMagick). Is there some utility, which can produce same or better quality to size ratio? ...

Removing duplicates in an array while preserving the order in C++

Possible Duplicate: How to make elements of vector unique? (remove non adjacent duplicates) Is there any standard algorithm which is provided as part of STL algorithms which can remove duplicates from an array while preserving the order. For example, if I have an array like int a[] = {2,1,3,1,4,2}; after the removal of duplica...

Power function fit

Hi. I want to fit a power function to a dataset. I'm using this method: http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html But the result is not acceptable: b = -0,001901, a = 7,26 My dataset: 8553600 458.2 17193600 373.6 25833600 694.16 34646400 738.33 44064000 817.89 54259200 1040.67 67910400 1032.69 762...