algorithm

calculating parameters for defining subsections of quadratic bezier curves

I have a quadratic bezier curve described as (startX, startY) to (anchorX, anchorY) and using a control point (controlX, controlY). I have two questions: (1) I want to determine y points on that curve based on an x point. (2) Then, given a line-segment on my bezier (defined by two intermediary points on my bezier curve (startX', start...

How to optimize an database suggestion engine

Hi, I`m making an online engine for item-to-item recommending movies. I have made some researches and I think that the best way to implement that is using pearson correlation and make a table with item1, item2 and correlation fields, but the problem is that after each rate of item I have to regenerate the correlation for in the worst cas...

nth item of hashmap

HashMap selections = new HashMap<Integer, Float>(); How can i get the Integer key of the 3rd smaller value of Float in all HashMap? Edit im using the HashMap for this for (InflatedRunner runner : prices.getRunners()) { for (InflatedMarketPrices.InflatedPrice price : runner.getLayPrices()) { if (price.getDepth() == 1...

algorithm to use to return a specific range of nodes in a directed graph

I have a class Graph with two lists types namely nodes and edges I have a function List<int> GetNodesInRange(Graph graph, int Range) when I get these parameters I need an algorithm that will go through the graph and return the list of nodes only as deep (the level) as the range. The algorithm should be able to accommodate large numb...

Choice of programming language for learning data structures and algorithms

Which programming language would you recommend to learn about data structures and algorithms in? Considering the following: Personal experience Language features (pointers, OO, etc) Suitability for learning DS & A concepts I ask because there are some books out there that are programming language-agnostic (written from a Mathemati...

A datastructure for Robotic Sort

I am trying to solve this problem : https://www.spoj.pl/problems/CERC07S/ I have identified that i need a datastructure in which reversing operations have lesser time complexity. I tried to create one using a doubly linked list, in which (i thought) reversing can be done in O(1) by just changing a value associated with the starting and...

Raytracing (LoS) on 3D hex-like tile maps

Greetings, I'm working on a game project that uses a 3D variant of hexagonal tile maps. Tiles are actually cubes, not hexes, but are laid out just like hexes (because a square can be turned to a cube to extrapolate from 2D to 3D, but there is no 3D version of a hex). Rather than a verbose description, here goes an example of a 4x4x4 map...

.NET Geometry Library

Does anyone know of a good (efficient, nice API, etc.) geometry open source library for .NET? Some of the operations needed: Data Structures Vectors (2D and 3D with floats and doubles) Lines (2D and 3D) Rectangles / Squares / Cubes / Boxes Spheres / Circles N-Sided Polygon Matrices (floats and doubles) Algorithms Intersection calcu...

Fast file search algorithm for IP addresses

Question What is the fastest way to find if an IP address exists in a file that contains IP addresses sorted as: 219.93.88.62 219.94.181.87 219.94.193.96 220.1.72.201 220.110.162.50 220.126.52.187 220.126.52.247 Constraints No database (e.g., MySQL, PostgreSQL, Oracle, etc.) Infrequent pre-processing is allowed (see possibilities...

Algorithm for Source Control System?

I need to write a simple source control system and wonder what algorithm I would use for file differences? I don't want to look into existing source code due to license concerns. I need to have it licensed under MPL so I can't look at any of the existing systems like CVS or Mercurial as they are all GPL licensed. Just to give some back...

Algorithm to generate dates for business days given the range of dates

I'd like to be able to calculate the dates of business days (mon-fri) given two dates d1 and d2. However in some locales the business days are sat-wed or sun-thur. Is there a facility in STL or C++ in general that allows for such a calculation? ...

Need help understanding this MATLAB function implementation

http://www.cc.gatech.edu/classes/AY2000/cs7495_fall/participants/sashag/ps3/getchaincode.m offset = N/2; %offset between ajacent pixels I don't understand what the above mean? ...

linear interpolation on 8bit microcontroller

I need to do a linear interpolation over time between two values on an 8 bit PIC microcontroller (Specifically 16F627A but that shouldn't matter) using PIC assembly language. Although I'm looking for an algorithm here as much as actual code. I need to take an 8 bit starting value, an 8 bit ending value and a position between the two (Cu...

Graph spacing algorithm

Hi, I am looking for an algorithm that would be useful for determining x y coordinates for a number objects to display on screen. Each object can be related to another object and there can be any number of relationships and there can be any number of these objects. There is no restriction on the overall size of area on which to display...

how to measure running time of algorithms in python

Possible Duplicates: Accurate timing of functions in python accurately measure time python function takes How can i mesure and compare the running times of my algorithms written in python .Also point me to a nice algorithms site/forum like stackoverflow if you can. ...

Algorithms for subgraph isomorphism detection

Subgraph isomorphism is an NP Complete problem. The most widely used algorithm is the one proposed by Ullman. Can someone please explain the algorithm to me in layman's language? I read the above paper by him, but couldn't understand much. What other algorithms exist for this problem? I am working on an image processing project. ...

Capturing time intervals when somebody was online? How would you impement this feature?

Hello, Our aim is to build timelines saying about periods of time when user was online. (It really doesn't matter what user we are talking about and where he was online) To get information about onliners we can call API method, someservice.com/api/?call=whoIsOnline whoIsOnline method will give us a list of users currently online. But t...

Finding unreachable sections of a 2D map

I don't want you to solve this problem for me, i just want to ask for some ideas. This is the input below, and it represents a map. The 'x' represents land, and the dots - water. So with the 'x' you can represent 'islands' on the map. xxx.x...xxxxx xxxx....x...x ........x.x.x ..xxxxx.x...x ..x...x.xxx.x ...

Looking for ideas how to refactor my (complex) algorithm

I am trying to write my own Game of Life, with my own set of rules. First 'concept', which I would like to apply, is socialization (which basicaly means if the cell wants to be alone or in a group with other cells). Data structure is 2-dimensional array (for now). In order to be able to move a cell to/away from a group of another cells,...

Stack and queue operations on the same array.

Hi. I've been thinking about a program logic, but I cannot draw a conclusion to my problem. Here, I've implemented stack and queue operations to a fixed array. int A[1000]; int size=1000; int top; int front; int rear; bool StackIsEmpty() { return (top==0); } bool StackPush( int x ) { if ( top >= size ) return false; A[t...