algorithm

Dynamic programming - Coin change decision problem?

I'm reviewing some old notes from my algorithms course and the dynamic programming problems are seeming a bit tricky to me. I have a problem where we have an unlimited supply of coins, with some denominations x1, x2, ... xn and we want to make change for some value X. We are trying to design a dynamic program to decide whether change f...

Proving that the distance values extracted in Dijkstra's algorithm is non-decreasing?

I'm reviewing my old algorithms notes and have come across this proof. It was from an assignment I had and I got it correct, but I feel that the proof certainly lacks. The question is to prove that the distance values taken from the priority queue in Dijkstra's algorithm is a non-decreasing sequence. My proof goes as follows: Pr...

integer division properties

hi. does the following integer arithmetic property hold? (m/n)/l == m/(n*l) At first I thought I knew answer (does not hold), but now am not sure. Does it hold for all numbers or only for certain conditions, i.e. n > l? the question pertains to computer arithmetic, namely q = n/m, q*m != n, ignoring overflow. ...

GRAPH PROBLEM: find an algorithm to determine the shortest path from one point to another in a rectangular maze?

I'm getting such an headache trying to elaborate an appropriate algorithm to go from a START position to a EXIT position in a maze. For what is worth, the maze is rectangular, maxsize 500x500 and, in theory, is resolvable by DFS with some branch and bound techniques ... 10 3 4 7 6 3 3 1 2 2 1 0 2 2 2 4 2 2 5 2 2 1...

What is an algorithm for minimizing some D distances between N items?

A classmate printed out a diagram of a database for class, the kind with lines representing relationships between tables. However, his lines crossed all over the place and it looked ugly. So I got to thinking about a way to move the tables to minimize the total line distance, and I couldn't think of a way to do it, other than just movin...

How to count the number of right children in a binary tree?

How to count the number of right children in a binary tree? This means that I only want the children marked as right. Ex. (Left | Right) F(Root) G | H T U | I J The right children would be U,H,and J. What would be the algorithm to find these. ...

How do I remove the leaves of a binary tree?

I'm trying to remove all of the leaves. I know that leaves have no children, this is what I have so far. public void removeLeaves(BinaryTree n){ if (n.left == null && n.right == null){ n = null; } if (n.left != null) removeLeaves(n.left); if (n.right != null) removeLeaves(n.right); } ...

Travelling Salesman Problem Constraint Representation

Hey! I read a couple of articles and sample code about how to solve TSP with Genetic Algorithms and Ant Colony Optimization etc. But everything I found didn't include time (window) constraints, eg. "I have to be at customer x before 12am)" and assumed symmetry. Can somebody point me into the direction of some sample code or articles t...

Algorithms for finding closest vector

I have a set of vectors. For a vector in that set I like to find the sub set that is closeest to this vector. What algorithm can do this. ...

how to describe this series in code?

hello, i would like to find a formula describing this series. i need to set a boolean depending on a positive integer. it's pretty simple but i am stuck and feel a bit stupid. 0 false 1 true 2 true 3 false 4 false 5 true 6 true 7 false 8 false 9 true 10 true 11 false 12 false ... so the flag changes at every odd number ...

Looking for an algorithm in vb.net or c# but I don't know it's name!

I'll do my best to explain what the algorithm is supposed to do: There's a class 'Recipe'. Each Recipe can include other Recipes but cannot include itself or any other Recipe that includes it. So, a simple example is we have just two Recipes A & B. If A adds B first, then later on B cannot add A because it will cause a loop. A more ...

What is the typical method to separate connected letters in a word using OCR

I am very new to OCR and almost know nothing about the algorithms used to recognize words. I am just getting familiar to that. Could anybody please advise on the typical method used to recognize and separate individual characters in connected form (I mean in a word where all letters are linked together)? Forget about handwriting, suppos...

Strategies for quickly traversing an ACL

We are currently working on a project where the main domain objects are content nodes and we are using an ACL-like system where each node in the hierarchy can contain rules that override or complement those on their parents. Everything is as well based on roles and actions, for example. Node 1 - {Deny All, Allow Role1 View} \- Node 2 - ...

What is the best algorithm to use in creating binary trees??

I've been doing a research about the best algorithm to use in creating a binary tree implementation. THe top entry in my list is nested sets. Are there any other alternative or better algorithm?? If possible can you give me a list of top algorithms so that I can research/study it and see if it will fit the system needs. ...

look for evaluation function in tictactoe 3d game

I'm trying to apply minimax algorithm for the game tictactoe 3D in c++. I'm struggling to find a good evaluation function for it. Does anybody know where has good resource to find the evaluation function? Thank you. ...

Is there a shorthand term for O(n log n)?

We usually have a single word for most complexities we encounter in algorithmic analysis: O(1) == "constant" O(log n) == "logarithmic" O(n) == "linear" O(n^2) == "quadratic" O(n^3) == "cubic" O(2^n) == "exponential" We encounter algorithms with O(n log n) complexity with some regularity (think of all the algorithms dominated by sort ...

Separate groups of people based on members

I have groups of people. I need to move groups with at least one same member as far as possible from each other. Example: GroupA - John, Bob, Nick GroupB - Jack, Nick GroupC - Brian, Alex, Steve As you can see GroupA and GroupB overlap(they both contain Nick) I need an algorithm to set groups as GroupA->GroupC->GroupB Thank you ...

Programming Technique: How to create a simple card game

Hi, as I am learning the Ruby language, I am getting closer to actual programming. I was thinking of creating a simple card game. My question isn't Ruby oriented, but I do know want to learn how to solve this problem with a genuine OOP approach. In my card game, I want to have four players, using a standard deck with 52 cards, no joker...

Algorithm to generate a segment maze

I want to generate a maze that looks like this: That is, it consists of paths in one direction that are then connected. I have looked for an algorithm to generate mazes like this without success. Specifically, I don't want a maze like this: because it doesn't "run" in only one direction. Also, it would be nice if the solution of t...

Algorithm Analysis tool for java

I am looking for an algorithm analysis tool for java that can calculate Big 0 of a function. Ideal I would like to make it part of my build process, along side of my other code metrics tool. Even after searching on google I am unable to find any opensource of commercial tool. Any suggestion would be welcome Thanks ...