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.

learn more… | top users | synonyms (2)

0
votes
0answers
15 views

How to find column index for top n values of a matrix efficiently?

Given a matrix, say m, is there any direct method to find top k values of m and then find exactly which column/row do they belong to. I couldn't find any on SO and hence, putting this question. My try ...
0
votes
2answers
32 views

solving the 2-sum algorithm in javascript

I'm trying to write a simple solution to the 2-Sum problem in Javascript. The problem goes: given an array of n integers and a target sum, determine what combinations of two integers will sum to the ...
1
vote
1answer
14 views

ArrayIndexOutofBoundsException in Knapsack Scala

I am trying to solve Knapsack problem in Scala using dynamic programming .As a part of requirement I also need to show which items are picked to be filled in Knapsack.But I am getting "...
0
votes
0answers
11 views

How to judge the contour is line or curve by opencv?

Guys. This image have two contours. I can find both with opencv findcontour function. What I want to know is how to judge which contour is line and which contour is curve ? Can anybody please tell how ...
0
votes
1answer
26 views

Convert a rating scale

I have a website where people can evaluate some subjects. Here is the scale [1-4]. However I probably have a problem in terms of readability of the overall rating. The most common scale is [1-5] in ...
0
votes
0answers
14 views

Looking for help to optimize Box-Triangle intersection algorithm

So recently I wrote an algorithm to generate decals. To do so I used code from https://www.geometrictools.com/ for an algo to find if triangles intersect with an aligned box. I was wondering how/if I ...
0
votes
0answers
28 views

Trouble understanding where to put exchanges/comparisons counters in heapsort

Heapsort should be such that BuildHeap is O(n) and Heapify O(logN), right? Overall efficiency O(NLogN)? But no matter where I've been placing my counters, for an array of 2000 elements I get around ...
-1
votes
2answers
28 views

Efficient method to check if point is within a diamond

I have an array of diamonds as shown in the image and I know the position of every diamond and the distance from the origin of the diamond to any vertex (They are all the same distance from the center)...
-3
votes
0answers
37 views

Diophantine equation in C

I need an algorithm of Diophantine equation for ax + by = c, where I know a, b and c. For example -25x+17y=9. I know I have to use Euclidean algorithm and if D/c, then I use the Diophantine equation, ...
-4
votes
1answer
27 views

Element uniqueness algorithm [on hold]

For my class, I am asked to solve an element uniqueness problem. I have a sample of code here which I have to implement. I need to perform an experimental analysis to determine the largest number of n ...
0
votes
0answers
18 views

Is there a way to make this method parsing tweets in Python efficient?

I have a script that queries Twitter then counts the most Retweeted tweets from the result sets. I am very new to programming, so the code is ugly for sure but it does what I want it to do. It does ...
0
votes
0answers
19 views

How to twist K-Means algorithm in R to find optimal assignment of service personal

I have a list (say 300) of customers (lat,long)- and a list (say 10) of service engineers (lat,long). I need to assign a service engineer for each customer in an optimal way. To reduce his travel and ...
2
votes
0answers
41 views

scanning a triangle from it's topmost vertex

The following three lines represent three vertices of a triangle in 3D : 0.3723886 0.2281803 0.9484826 (vertex A) 0.7105783 0.6288340 0.9638510 (Vertex B) 0.1625506 0.7013804 0.9763735 (Vertex C) ...
0
votes
0answers
17 views

How does constraint solving work and how can I implement one?

I'm learning about about programming languages, specifically implementing a compiler for one. Everything so far works, but I wanted to add a more sophisticated type inference algorithm. I've heard ...
-3
votes
1answer
24 views

Check if an array of strings has all elements to create a given word

Say you have an array of words String[] arr = {"i", "a", "am", "good", "program", "gram"}; And a given key String key = "iamgood"; boolean allWordsFound(arr, key){ // should return true if all ...
-1
votes
0answers
26 views

Perimeter/length of boundary of a binary image in cpp

I am tasked with the following problem. I am given a binary image of a certain shape (no holes and no disjoint pieces) which is in a form of a 2D matrix. I have to find the "length of the fence" (...
0
votes
0answers
21 views

Single-community detection algorithm

Here is a presentation of my dataset : Large social-network composed of Twitter accounts followers of very large related accounts, followers of this followers, and followers of these followers, at ...
-5
votes
0answers
21 views

Make all possible teams of 6 players form a list of 16 players in php [on hold]

I have a list of players and i want to make teams of 6 players, Like one team has 6 players, then the other team has six players, but all of the teams must not have similar players. One player may ...
0
votes
1answer
13 views

Fill grid's datasource with distinct combinations of data

I have one problem about filling a grid. Okey, Imagine we have a grid which prints some data about basketball team. We have four main classes: public class Player { public string PlayerName ...
4
votes
4answers
116 views

How to make the most effective search in array

I had a question in a job interview: find first unique name in array. public static void Main(string[] args) { Console.WriteLine(FirstUniqueName(new string[] { "Abbi", "Adeline", "Abbi", "...
1
vote
1answer
14 views

Finding a path through a connected component where every vertex is visited exactly once

I have a large graph of connected vertices (a connected component) and I am looking for a path that goes through all of them, but never goes through one vertex twice. This isn't always possible. For ...
0
votes
0answers
21 views

Generating json object with specific format from a collection

I'm trying to use the jQuery bracket plugin (http://www.aropupu.fi/bracket/). As you can see, the plugin asks for an specific format in the json object. Example here: var minimalData = { teams : ...
1
vote
1answer
27 views

Getting Logical Subexpressions Using Stack

I don't have any code right now, but I'm simply trying to process how I'm going to perform this algorithm and I just need some ideas. Say I have the String for example: ((A+B)*(C+B)) * (A+C) I don'...
-2
votes
1answer
25 views

How to use lower_bound(upper_bound) to find position of any number in array?

For example, I have an array with elements 1,7,9,23,34,47,67,89,123,234,345,567. I need to know the position of 123.
-2
votes
0answers
8 views

Why Go-Back-N ARQ send duplicate frame? [on hold]

What is Go-Back-N ARQ advantage and disadvantage? Why it send duplicate frame?
0
votes
0answers
14 views

How to negate the device rotation from the initial pose(transformation) matrix of an object

To give some context, I would like to get the rotation of a marker in its own frame of reference given that I only have its transformation matrix (marker to camera). That said, that means the camera ...
0
votes
0answers
29 views

calculating point of intersection between far or near plane and a triangle

Suppose, the near and far values of gluPerspective are 1 and 100 respectively. I want to clip the portion of the triangle having z values greater than (-near) or less than (-far) and divide the ...
0
votes
0answers
9 views

Printing data according to weights or ratios from different data source or collection or array

I have a requirement where i have some data stored in arrays(it is not language specific). Lets assume i have 3 arrays name Array1 which has values 1,2,5,6,7,9,10. Array2 hello,how,are,you. and Array3 ...
4
votes
3answers
88 views

Fast data structure or algorithm to find mean of each pixel in a stack of images

I have a stack of images in which I want to calculate the mean of each pixel down the stack. For example, let (x_n,y_n) be the (x,y) pixel in the nth image. Thus, the mean of pixel (x,y) for three ...
0
votes
1answer
29 views

How can i improve openCV people detecting algorithm

I am trying to write human detector, it works now, but sometimes it reacts on cats/boxes etc., also i got like 5 fps. So the question is, how can i improve my algorithm for better fps and detection ...
2
votes
2answers
24 views

Find closest “true” element in 2D boolean matrix?

I have a 2D matrix with boolean values, which is updated highly frequently. I want to choose a 2D index {x, y} within the matrix, and find the nearest element that is "true" in the table, without ...
0
votes
0answers
27 views

Flaw in a published binary thinning algorithm

I am using the binary image thinning algorithm found as "Graphics Gems IV. Binary Image Thinning Using Neigborhood Maps", by Joseph M. Cychosz. An implementation can be found online at https://github....
0
votes
2answers
25 views

Are both conditions necessary (optimal structure and overlapping subproblem) for dynamic programming approach?

Does every problem of DP posseses both property or any single property is sufficient ? If both conditions are necessary, i can't see optimal substructure in knapsack problem.
0
votes
2answers
23 views

What “big-data” algorithms can I use in order to analyze similarites between text files?

I would like to create a system which gets a lot of text files (this system gets some text files every 2 minutes) and find the ones which have the at least one common sentence. What algorithms can I ...
3
votes
1answer
64 views

SHORTEST delivery time by 2 transporters

I am dealing with an algorithmic problem. I have a known graph algorithm with a single central node. The aim is to deliver goods from this central node to some other, specified nodes by TWO ...
1
vote
2answers
56 views

Numpy: how to find the unique local minimum of sub matrixes in matrix A?

Given a matrix A of dimension MxN (4x4), how would one find the next-best minimum of each 2x2 submatrix? A = array([[ 32673. , 15108.2 , 26767.2 , 9420. ], [ 32944.2 , ...
1
vote
1answer
76 views

Why is Java producing faulty output for lengths > 10000 in this algorithm?

I have this assignment for university, where we are supposed to implement a sorting algorithm similar to insertion sort. The algorithm has a data Structure consisting of 2 Stacks S and T. The elements ...
0
votes
0answers
15 views

LZW or JBIG is better lossless compression algorithm for images?

Which lossless compression algorithm [between LZW or JBIG] is better for compressing data sets consisting of images (colored and monochrome) ? I have implemented both and tested on smaller data sets [...
2
votes
1answer
42 views

Algorithm to find best offer combination that gives maximum discount on a given set Of Items

I have items with ID (1001, 1002, 1003, 1004, 1005, 1006). There respective quantities are (2, 5, 1, 1, 5, 2): Now I have data like following.There is an offerId for each row. offerId :{[Item_Id, ...
2
votes
1answer
41 views

Covering N line segments with unit disks

Given a set of N disjoint horizontal line segments (parallel to the X-axis) of variable length and variable perpendicular distances in between, we need to place minimum numbers of unit disks that ...
4
votes
1answer
74 views

Unique hash with maximum of 4 characters?

What is the best method to create a hash of String, if the hash may not have more than 4 characters, and those 4 characters may only be lowercase letters or digits? The strings I want to hash have 1-...
-4
votes
0answers
20 views

How can we find region containing table structure in a document image?

Given a document image after performing morphological operation, I want to locate region containing table structure. Few screens are attached below.
0
votes
1answer
39 views

When does grouping in radix-sort give an advantage?

I have been testing this implementation of radix-Sort: public void RadixSort(int[] a) { // our helper array int[] t=new int[a.Length]; // number of bits our group will be long int r=4; // try ...
1
vote
0answers
44 views

How to find points positions to minimize line interaction?

So this is my problem, I have n nodes (can be called points without positions), and I have a list of lines, were a line is defined by connecting 2 nodes (points). My problem is to find the right ...
3
votes
1answer
45 views

Consecutively intersect two sets of intervals

We have two sets of intervals, A and B. Every inteval in A is described by two positive real numbers {A1start,A1end},{A2start,A2end},...,{Anstart,Anend}. Anend is alsways > Anstart. Intervals in A ...
0
votes
2answers
16 views

Find next highest lexicgraphic permutation of a string [duplicate]

given a string W, what i want to achieve its next string lexicographically greater. eg 1: givenstring = "hegf" nexthighest = "hefg" what i have tried till now is here, from itertools import ...
0
votes
0answers
26 views

Genetic Algorithm Crossover Operation Techniques

What are the possible crossover techniques for genetic algorithms with direct value encoding that preserve the fixed size length of the chromosome? For example suppose we have two parents that are ...
0
votes
0answers
24 views

Understanding Output and error of artificial neural network

I'm trying to write AI for tetris. AI is based on Multilayer NN. Input is equal to stage of board output is a vector or possible moves. For example [1,0,0,0,0] means [moveLeft,0,0,0,0], and I want to ...
-4
votes
1answer
30 views

What do I need to create an app that summarizes text from a document (include 100-150 characters)? [on hold]

I want to create an feature which can summarizes text from a document in Android. I am confusion about algorithm to do it Any support from anyone will be appreciate
2
votes
2answers
54 views

Cartesian product with specific criteria

I am attempting to find the cartesian product and append specific criteria. I have four pools of 25 people each. Each person has a score and a price. Each person in each pool looks as such. [0] =&...