Questions tagged [algorithm]
An algorithm is a sequence of well-defined steps that defines an abstract solution to a problem. Use this tag when your issue is related to algorithm design.
                                	
	algorithm
    
                            
                        
                    
            23,732
            questions with no upvoted or accepted answers
        
        
            15
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    Computing a move score in a Minimax Tree of a certain depth
                I've implemented a Chess game in C, with the following structs:
move - which represents a move from (a,b) to (c,d) on a char board[8][8] (Chess board)
moves - which is a linked list of moves with ...
            
        
       
    
            12
            votes
        
        
            1
            answer
        
        
            428
            views
        
    Algorithm itemset matching pattern
                I've a set of elements (potentially big) with an order relation:
[a,b,c,d,e,f] 
and a set of frequent patterns (potentially big) with ids:
[a]:1,[b]:2,[c]:3,[a,b]:4,[b,c]:5,[a,b,c]:6
I have a ...
            
        
       
    
            12
            votes
        
        
            5
            answers
        
        
            2k
            views
        
    Check if there exist a path between two vertices in directed acyclic graph - queries
                This question can be easily solved in O(n + m) per query, however is this possible to answer such queries in better complexity with preprocessing better than O(n²) ? 
In tree it can be easily done by ...
            
        
       
    
            12
            votes
        
        
            1
            answer
        
        
            9k
            views
        
    Abstract syntax tree using the shunting yard algorithm
                I have an infix expression that I have tokenised and would like to proceed to create an abstract syntax tree. I understand the shunting-yard algorithm used in these cases. I have only found ways to ...
            
        
       
    
            11
            votes
        
        
            0
            answers
        
        
            266
            views
        
    Is the libc++ implementation of the STL deque push_front function standards-compliant?
                The C++ Standard (N4901) says this with reference to the deque push_front function:
An implementation shall provide these operations for all container types shown in the “container” column, and shall ...
            
        
       
    
            11
            votes
        
        
            0
            answers
        
        
            2k
            views
        
    GUI layout algorithms overview
                I'm looking for systematic review of the algorithms used for GUI layout. I'm particularly interested in the algorithms that favor speed over complexity, but it's hard to find anything useful other ...
            
        
       
    
            11
            votes
        
        
            1
            answer
        
        
            5k
            views
        
    DIvisive ANAlysis (DIANA) Hierarchical Clustering
                (This post is continuation of my previous question on divisive hierarchical clustering algorithm.)
The problem is how to implement this algorithm in Python (or any other language).
Algorithm ...
            
        
       
    
            11
            votes
        
        
            1
            answer
        
        
            421
            views
        
    Average case algorithm analysis using Kolmogorov Incompressibility Method
                The Incompressibility Method is said to simplify the analysis of algorithms for the average case. From what I understand, this is because there is no need to compute all of the possible combinations ...
            
        
       
    
            11
            votes
        
        
            2
            answers
        
        
            944
            views
        
    How are fluid simulations integrated into Rigid Body physics engines?
                Is there any proof that simulations that mix Rigid Body physics and fluids (say SPH) can provide modeling for real world?
How does a frame of such mix work?
Say we have a wooden swing inside a box ...
            
        
       
    
            11
            votes
        
        
            1
            answer
        
        
            1k
            views
        
    My implementation of the evaluation function and Alpha-beta pruning for Connect Four is not smart enough
                I am trying to implement correctly the Connect Four game AI yet not to avail my AI acts stupid: 
It does not block the opposite player pattern which can lead to failure of the AI,
It does not take ...
            
        
       
    
            10
            votes
        
        
            0
            answers
        
        
            345
            views
        
    Why does C++11 require std::sort to have WCET O(n log n)?
                Since C++11, the C++ Standard Library (c.f. Section 25.4.1.1 of a draft verion of the standard) requires the std::sort algorithm to have asymptotic worst case execution time O(n log n) instead of ...
            
        
       
    
            10
            votes
        
        
            3
            answers
        
        
            1k
            views
        
    Minimum add to make parentheses string consisting of '{', '}', '[', ']', '(', ')' valid
                This problem is an addition to the familiar stack question(https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/) where we have to return the minimum number of additions to make the ...
            
        
       
    
            10
            votes
        
        
            0
            answers
        
        
            2k
            views
        
    Can I guess the appropriate epsilon for RDP (Ramer-Douglas-Peucker)?
                I have sets of time series data which I display as charts in mobile applications.
To make the charts clearer, I simplify the sets by applying Ramer-Douglas-Peucker.
If I apply RDP to a small set ...
            
        
       
    
            10
            votes
        
        
            2
            answers
        
        
            154
            views
        
    Strategy for translating a UX `pan` gesture to set a linear value without an upper bound
                I'm trying to set a slider (actually a kitchen timer) using a pan gesture in ionic2 see: http://ionicframework.com/docs/v2/components/#gestures
The slider/timer has an open upper-bound that could be ...
            
        
       
    
            10
            votes
        
        
            3
            answers
        
        
            12k
            views
        
    Parenthesizing a string so that expression takes a given value
                The following problem is from the chapter on Dynamic Programming by Vazirani et. al.
[6.6]Let us define a multiplication operation(×) on three symbols a; b; c according to the following table:
...
            
        
       
    
            9
            votes
        
        
            0
            answers
        
        
            337
            views
        
    Multiset domination algorithm
                Let us say that a multiset M dominates another multiset N if each element in N occurs at least as many times in M.
Given a target multiset M and an integer k>0, I'd like to find a list, L, of size-k ...
            
        
       
    
            9
            votes
        
        
            2
            answers
        
        
            429
            views
        
    Autogram Algorithms
                An autogram is a sentence which describes its letters. For example, from Wikipedia:
  This sentence employs two a’s, two c’s, two d’s, twenty-eight e’s,
  five f’s, three g’s, eight h’s, eleven i’s, ...
            
        
       
    
            9
            votes
        
        
            4
            answers
        
        
            1k
            views
        
    How to determine whether removing a given cycle will disconnect a graph
                I have seen ways to detect a cycle in a graph, but I still have not managed to find a way to detect a "bridge-like" cycle. So let's say we have found a cycle in a connected (and undirected) graph. How ...
            
        
       
    
            9
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    Algorithm for offsetting edges of 3D triangle mesh
                I have a 3D triangle mesh, and I'm looking for an algorithm to offset all the un-bordered edges border edges of the mesh inwards, along the surface of the triangle mesh.
I've looked at Clipper as ...
            
        
       
    
            9
            votes
        
        
            2
            answers
        
        
            365
            views
        
    Is there an implementation of the idea described in "Detecting NearDuplicates for Web Crawling"
                The paper: http://www2007.org/papers/paper215.pdf 
I am just wondering are there any implementations of chapter 3 of that paper. I mean querying among large datasets, NOT only the simhash (it's easy ...
            
        
       
    
            8
            votes
        
        
            1
            answer
        
        
            4k
            views
        
    2D Bin Packing Algorithm
                I have spent some time researching 2d bin packing algorithm. I have no extensive experience in algorithm especially in advanced math but I can code :)
The perfect example of what I need to achieve is ...
            
        
       
    
            8
            votes
        
        
            0
            answers
        
        
            194
            views
        
    which design considerations justify std::make_heap() to be apparently sub-optimal?
                According to cppreference (and the requirement in the C++ standard) std::make_heap() takes at most 3n comparisons, but according to Wikipedia no more than 2n comparisons are actually needed.
What are ...
            
        
       
    
            8
            votes
        
        
            1
            answer
        
        
            402
            views
        
    Proposing an algorithm for arbitrary shape Bit Matrix Transposition with BDD-like structure
                We consider a bit matrix (n x m) to be a regular array containing n lines of integers of size m.
I have looked in Hacker's Delight and in other sources and the algorithms I found for this were rather ...
            
        
       
    
            8
            votes
        
        
            0
            answers
        
        
            3k
            views
        
    Python implementation of Multiple-Choice Knapsack
                I have been searching for python implementation of multiple choice knapsack problem. So far I have found a java implementation in github: https://github.com/tmarinkovic/multiple-choice-knapsack-...
            
        
       
    
            8
            votes
        
        
            1
            answer
        
        
            947
            views
        
    How to find cycles of a given length in a directed graph? (Using networkx)
                I'm trying to find cycles of length 2, 3, 4, and 5 in a directed graph. So far I've had decent luck on most inputs using the simple_cycles algorithm from networkx (https://networkx.readthedocs.io/en/...
            
        
       
    
            8
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    Active Shape Models: matching model points to target points
                I have a question regarding Active Shape Models. I am using the paper of T. Coots (which can be found here.)
I have done all of the initial steps (Procrustes Analysis to calculate mean shape, PCA to ...
            
        
       
    
            8
            votes
        
        
            3
            answers
        
        
            539
            views
        
    Algorithm : Letters and envelopes pairing
                Disclaimer : This isn't any kind of homework, the problem just came to my mind while I was going through all the Christmas cards
The problem is given as follows : We've got M envelopes and N letters, ...
            
        
       
    
            8
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    How do I balance a BK-Tree and is it necessary?
                I am looking into using an Edit Distance algorithm to implement a fuzzy search in a name database.
I've found a data structure that will supposedly help speed this up through a divide and conquer ...
            
        
       
    
            8
            votes
        
        
            3
            answers
        
        
            8k
            views
        
    Count number of cycles in directed graph using DFS
                I want to count total number of directed cycles available in a directed graph (Only count is required). 
You can assume graph is given as adjacency matrix. 
I know DFS but could not make a working ...
            
        
       
    
            7
            votes
        
        
            0
            answers
        
        
            254
            views
        
    Elegant algorithm to control max value for carousel
                I have a slider which at most can show 3 elements. If there are more elements, these are hidden and
can come into view by clicking left right as following image.
This slider will be taking in a ...
            
        
       
    
            7
            votes
        
        
            0
            answers
        
        
            243
            views
        
    Minimise the median of the distances from a string
                The problem
Lets consider you have a list of strings r, s, t, .... How could you determine the string u such as M = Med(d(r, u), d(s, u), d(t, u), ...) is minimised?
d is a function which returns ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            308
            views
        
    Optimal covering with non-uniform discs
                What kind of algorithm can I use to search for an optimal (minimum area) covering of a limited region of the XY plane with n discs ( xj, yj, rj ) ?
I've found many investigations on fixed radius discs,...
            
        
       
    
            7
            votes
        
        
            2
            answers
        
        
            782
            views
        
    Find minimum number of triangles enclosing all points in the point cloud
                Input
You have a points list which represents a 2D point cloud.
Output 
You have to generate a list of triangles (should be as less as possible triangles)  so the following restrictions are ...
            
        
       
    
            7
            votes
        
        
            2
            answers
        
        
            2k
            views
        
    Directed Acyclic Graph with Hierarchical Layout
                I am trying to programmatically build a family tree. I don't care what format the input data is in, as text is easy to parse (I'm an NLP researcher), but I'm having trouble figuring out how to build (...
            
        
       
    
            7
            votes
        
        
            0
            answers
        
        
            212
            views
        
    Is there a more concise way to implement css' An+B micro-syntax as xpath predicates?
                I'm creating a CSS selectors to xpath 1 converter and one detail I struggled the most with is finding a concise substitute for the An+B micro-syntax.
Since I'm implementing it for xpath 1 and in such ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            256
            views
        
    Topologically sort DAG into batches
                I'm looking for an algorithm to sort a DAG into batches of vertices, such that no vertices in a batch have an edge between them, and the batches are sorted in an order such that no vertex in a batch ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            3k
            views
        
    Surface Area Heuristic (SAH) kd-tree of triangles - flat cells
                I've implemented a SAH kd-tree based upon the paper On building fast kd-Trees for Ray Tracing, and on doing that in O(N log N) by Wald and Havran. Note I haven't done their splicing and merging ...
            
        
       
    
            7
            votes
        
        
            0
            answers
        
        
            2k
            views
        
    Graph algorithm: simplify graph by replacing chains of nodes with single node
                I'm looking for a directed weighted graph simplification algorithm that seeks chains of nodes which have exactly one inbound edge and exactly one outbound edge and are interconnected and replaces such ...
            
        
       
    
            7
            votes
        
        
            2
            answers
        
        
            2k
            views
        
    How to calculate distance between 2D matrices
                Hello Community, 
  I'm new (as a member) to the site, so if you think it might be better to post it on http://datascience.stackexchange.com, let me know. 
I am tackling a Machine Learning problem ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            1k
            views
        
    SGM Disparity subpixel estimation - how to?
                Some weeks ago I've implemented a simple block matching stereo algorithm but the results had been bad. So I've searched on the Internet to find better algorithms. There I found the semi global ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    Parametric equation to place a leaflet marker on the circumference of a circle is not precise?
                I am working on an application where I have the center of a circle and the radius and I am plotting the circle with the help of Leaflet.
I placed a marker on the north most end of the circumference ...
            
        
       
    
            7
            votes
        
        
            0
            answers
        
        
            3k
            views
        
    iOS Swift Flood fill algorithm
                I created this extension for "bucket fill" (flood fill) of touch point:
extension UIImageView {
    func bucketFill(startPoint: CGPoint, newColor: UIColor) {
        var newRed, newGreen, newBlue, ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            886
            views
        
    Range Query the number of inversion in O(lg N)
                Given an unsorted array of n integers, I know I can find the total number of inversions using BIT in O(N lg N)following this method: Count Inversion by BIT
However is it possible if I have to query ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            982
            views
        
    Symbol Directed Graph using data from text file
                I'm so stuck, I would greatly appreciate some help. I'm currently learning Algorithms, but I have no idea where to start.
I was given code recently (We have only really done theory so seeing the code ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            2k
            views
        
    Uniformly arranging points on a sphere using Fibonacci Lattices
                I'm trying to arrange points more-or-less uniformly along the surface of a unit sphere.
I'm told that while this problem is difficult, Fibonacci Lattices give a very good solution.
I've been trying ...
            
        
       
    
            7
            votes
        
        
            5
            answers
        
        
            591
            views
        
    How can I find a way to minimum the number of edges?
                I am thinking an algorithm to solve the problem below:
A given graph composed of vertices and edges.
There are N customers who want to travel from a vertex to another vertex.
And each customer ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            580
            views
        
    How to find the best (most informative) plotting limits?
                I am developing a 2D plotting program for functions of 1 variable. It is designed to be very simple so that the user should not have to select the initial plot limits (or "range").
Are there known ...
            
        
       
    
            7
            votes
        
        
            1
            answer
        
        
            287
            views
        
    Counting unvisited nodes at distance n for every node in graph
                For each point in a large graph I am trying to create a list that contains the number of unvisited nodes at distance n from the starting node. An example output is:
[1,3,6]
which means that at ...
            
        
       
    
            7
            votes
        
        
            5
            answers
        
        
            4k
            views
        
    How to find if a 3D object fits in another 3D object (the container)?
                Given two 3d objects, how can I find if one fits inside the second (and find the location of the object in the container).
The object should be translated and rotated to fit the container - but not ...
            
        
       
    
            7
            votes
        
        
            2
            answers
        
        
            2k
            views
        
    Efficient algorithm for removing loops from polylines
                I have a polyline, given as an ordered set of (X,Y) coordinates, that may cross over itself to form one or more loops.  From this, I want to extract a polygon that has the loops removed, which will ...