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
2 views

Find Rect bounds of largest Rectangle in a matrix

I'm modifying this maximal rectangle algorithm to not only find the max rectangle in a matrix but also return the left, right, top and bottom bounds. I've got it to the point of correctly returning ...
1
vote
0answers
9 views

efficient algorithms with array of increasing integers

I've been self teaching myself data structures in python and don't know if I'm overthinking (or underthinking!) the following question: My goal is come up with an efficient algorithm With the ...
0
votes
0answers
9 views

Search Multiple Sources for Data

I am building a search for cars. I want to search through multiple apis/databases and output the top ten cars that match my input values - make, model, year, color ... My search model looks like this ...
-1
votes
2answers
31 views

Combinations/ permutations of numbers in array c#

I need to get all the permutations in array of a concrete length, e.g. source = { 1,2,3,4 }, count=1 => {{1},{2},{3},{4}} source = { 1,2,3,4 }, count=2 => {{1,2},{1,3},{1,4},{2,3},{2,4},{3,4}} ...
0
votes
3answers
43 views

Declaration with array, C

I'm studying arrays in C, and I'm trying bubble-sort algorithm. I do (in a main function): int main{ srand(time(NULL)); //Randomize int SIZE = (rand() % 20) + 1; int number[ SIZE ] = { 0 }; ... } ...
1
vote
1answer
25 views

Javascript flood fill algorithm getting caught in an infinite loop

Hello I am trying to implement a simple flood fill type algorithm in javascript. Basically I have a 3x3 board which I represent as a 1 dimensional array. I want to append the index for every equal ...
0
votes
1answer
23 views

finding the edge connection point between two AABB area

Lets say I have two AABB based areas, they are defined by coordinates mins{x, y} and maxs{x, y}, I need to find the middle connection point between them. Since my english is not good, I can't explain ...
0
votes
0answers
10 views

What is the algorithm behind GROUP USING 'collected' and 'merge'

Pig documentation says if some conditions are met(these conditions are described in doc), Pig can do map side GROUP. Can someone explain this algorithm? I want to get a deep understanding of what can ...
-2
votes
0answers
31 views

How get list of all child nodes names in Perl [on hold]

I want to print all the names of child and sub child nodes using Perl Suppose we have structure is like: A A1 A2 A3 A2 B2 A3 C2 C3 C4 Here A is Parent and which has childs ...
0
votes
1answer
50 views

Finding snake sequence in XY graph - Java

I am working on a problem to try to find what is called a Snake Sequence in a typical XY graph (aka grid). A Snake sequence is defined as a sequence of numbers where each new number, which can only be ...
0
votes
2answers
31 views

Generating series numbers with adding String at middle

Am writing JavaScript plugin to one of my client, in this i need to generate a series strings like "1,2,D,3,4" / "1,D,2,3,4,5,6". length can be n numbers. "D" positions are stored in a separate string ...
-4
votes
1answer
17 views

Is it 2 character search possible in lucence

Hi i have a question about lucence search Is it possible to search a 2 character from file using lucence search For ex. if there are names like "karthik test" is it possible to search for "ka" or ...
0
votes
1answer
44 views

Algorithm analysis for below function

I have made a solution of chaining coin problem using recursion. I want to know to calculate the big oh complexity for this solution. int chainingCoinRec(int val[], int p){ int ...
2
votes
1answer
51 views

Efficient method using only bit-wise operations

We are given n binary numbers, each of k bits. We need to find a k bit binary number in which ith bit is set only if the ith bit was set in exactly one of the n given binary numbers. For example, ...
0
votes
0answers
37 views

Sort an array which results in maximum product of elements

I am working on a problem which involves taking an integer array as an input from the user. The program calculates product of the elements of the array. The calculation goes as follows: for eg, let ...
2
votes
0answers
27 views

Convert an array of paths into a JSON tree [on hold]

I am trying to visualize a taxonomy that I have fetched from a web service. The following is a sample of the taxonomy which is an array of JS objects. To proceed with my viz I need to convert it into ...
-1
votes
2answers
55 views

Dijsktra's Algorithm Implmentation : Mice and Maze

This is a simple problem involving Dijkstra's Algorithm to find shortest distance tree rooted at a given vertex. Following is the code that got accepted: #include<iostream> ...
0
votes
2answers
60 views

Improve code with several booleans conditions java

I got a big problem to deal with, my code is too long and full characters. I removed a lot, using methods and using some proper design patterns... But it is still too "crowded". I get a string from ...
1
vote
3answers
58 views

Tile Filling Algorithm for Game

Background: I am working on a tile-based game in Javascript where a character freely moves around the map (no diagonal - Left/Right/Up/Down) and fills in tiles as he moves around the map. There are ...
0
votes
0answers
25 views

Algorithm for merging rectangles/polygons

Short version: I'm looking for an algorithm that helps me solve a seemingly simple task: I have a bunch of rectangles that may be touching each other but will not overlap. I want to merge them into ...
-4
votes
1answer
60 views

Given two words which are anagrams. Swap one word (only adjacent swapping of letters allowed) to reach to the other word [duplicate]

This is the interview question Given two words that are anagram of each other. Swap one word (only adjacent swapping of letters allowed) to reach to the other word ? for example given = abcd ...
1
vote
1answer
52 views

Remainder algorithm of byte array with unsigned int

Given a byte array in C++ (templated function) of a fixed size, and an unsigned integer, how can I calculate the remainder (normally the % operator for integers). Here is how I currently do it using ...
1
vote
1answer
26 views

std::transform in Visual Studio fails using own iterators

In a bigger project, I defined some class which defines its own iterator in a very minimalistic way. Up to now I gave my code gcc and clang, they ate it and were very happy after compiling. Today I ...
0
votes
3answers
29 views

Finding the only pair in a sorted array A whose sum is equal to K

I know this question has been asked so much times. However, after digging throughout all related posts on StackOverflow, I still don't find the deterministic answer. Can you help? My question is that ...
-4
votes
2answers
31 views

Create a list of lists from one list by uniques [on hold]

I'm trying to convert the following list: [1,2,2,4,2,1,5,4,3] To this list of lists: [[1,1],[2,2],[3],[4,4],[5]] Does anyone know a quick way to do this? I'm going to be running this on a very ...
0
votes
0answers
51 views

Round robin checking in an array

Basically i have an array consist of boolean values. i wanna check an array via round robin method. for example: i declare 2 array of structure, A= boolean of state P = process time at T=0 ...
5
votes
2answers
87 views

How can I efficiently generate an array of all possible alphabetical combinations of a given length of letters?

Imagine I have a bag of 26 scrabble tiles - one for each letter in the English alphabet. My goal is to create an array of all possible strings up to n letters long. Say n=3. Constraints: Letters ...
-1
votes
0answers
57 views

How to to put the power of N in time lgN? [on hold]

I would like to calculate a to the power of b. Here is how I can do this in linear growth: public int pow(int a, int b){ int result = 1; for(int i = 0; i < b; i++) { result = ...
-1
votes
0answers
32 views

Return number of letters in the same location in two strings

I have two NSStrings, string1 and string2 I want to look at the letters in each string and figure out how many letters are the same letter in the same position in both strings. I need the fastest ...
0
votes
3answers
43 views

Replacing a char in ruby with another char

I'm trying to replace all spaces in a string with '%20' but it's not producing the result I want. I'm splitting the string, then going through each char, if the char is " " I want to replace it with ...
0
votes
0answers
18 views

Looking for a variation of a script that runs the Luhn Algorithm, but also identifies the card type

I currently have a C program that runs the Luhn Algorithm against an input to determine it is a valid credit card number. However I'd like a script that also identifies the type of card, such as ...
0
votes
2answers
43 views

Generating permutations in VBA

This question has been asked before, but I can't find an answer that is easily applicable to Excel VBA. Basically I want to do exactly what this poster has asked, but in VBA. I want to create an ...
0
votes
1answer
184 views

Count different arrangments [on hold]

Few friends are going to a party. Each person has his own collection of T-Shirts. There are 100 different kind of T-Shirts. Each T-Shirt has a unique id between 1 and 100. No person has two T-Shirts ...
-1
votes
1answer
304 views

Consecutive Segment with exactly k even numbers [on hold]

Given an array of size n that contains positive integers. We need to find if it is possible to choose a consecutive non-empty segment of the array such that the segment should contain exactly k even ...
0
votes
0answers
13 views

porting/implementing R data mining algorithms to SQL Server

I am learning R and I have access to the MS SQL Server, particularly the Adventure Works Data Warehouse (2012). I am analyzing various tables / views in R, to try out various data mining techniques. ...
-3
votes
0answers
45 views

Data Structure and algorithm to get top 10 from infinite data.? [on hold]

I saw an interview question. You will be receiving an infinite sequence of numbers continuously and at any particular moment find the 10 largest ten numbers received till now I was thinking ...
4
votes
2answers
61 views

Closest pair algorithm for comparing points from 2 different arrays

I would like to compare the points from one array to the points from another array and find the closest pair. Till now whatever I have come across is with a single array. I do not want to compare the ...
0
votes
0answers
29 views

complexity of Bucket sort (uniform keys)

http://en.wikipedia.org/wiki/Sorting_algorithm#Comparison_of_algorithms The following table describes integer sorting algorithms and other sorting algorithms that are not comparison sorts. As such, ...
0
votes
0answers
27 views

Match multiple binary trees in another big binary tree

I was wondering if there is any efficient algorithm for finding matches for a set S = {t_1, t_2, ..., t_n} of small binary-trees in a big binary-tree T? The binary trees here are ordered and labeled, ...
0
votes
0answers
36 views

Efficient way to validate a Connect Four game

I'm scanning a Connect Four game with opencv into a data structure similar to this one (by John Tromp). Basically it uses a 7 x 7 bitboard (with only zeros in the top row) for each player to be able ...
0
votes
0answers
37 views

Algorithm to search area on planet

I've got spahes defined somwhere on earth. I've got geographic coordinates of each of them. I need to find these of them which are in specified distance repeatedly. I've got exact distance calculation ...
0
votes
0answers
42 views

ipod inventory and transportation algorithm

I am trying to solve the ipod inventory problem whose problem statement is as follows Recently a new online store opened on the Internet that sells iPods & iPhones. They are faced with an ...
0
votes
3answers
35 views

Return the Boss in the hierarchy — Tried to apply Depth First Search

XYZ is a company which has CEO Bill and a hierarchy of employees. Employees can have a list of other employees reporting to them, which can themselves have reports, and so on. An employee with at ...
1
vote
3answers
50 views

Find most common sub-string pattern in a file

You are given a string like: input_string = """ HIYourName=this is not true HIYourName=Have a good day HIYourName=nope HIYourName=Bye!""" Find the most common sub-string in the file. Here the ...
0
votes
1answer
58 views

What is the time complexity for T(n)=T(cn)+T((1-c)n)+n^2 [on hold]

What is the time complexity for T(n)=T(cn)+T((1-c)n)+n^2 0<c<1 thanks
2
votes
1answer
34 views

Maximise sum of pairwise distances in array

Imagine a list [e1, e2, ..., en] and a function f(e1, e2) -> number that returns the distance between any two elements in constant time. f(e, e) = 0 e1 != e2 => f(e1, e2) > 0 f(e1, e2) <= ...
1
vote
1answer
68 views

Can this “attack” really cause quicksort to degrade to quadratic running time even if items had been randomly shuffled?

A Killer Adversary for Quicksort claims to have a method of reducing any quicksort implementation to quadratic time. I guess this means that it will always produce a list that will always take O(n^2) ...
2
votes
1answer
46 views

How can I connect two parallel 2d polygons to create a seamless 3d mesh?

Suppose I have two polygons, one just above the other like this: I'd like to connect up their vertices to create a 3d mesh out of triangles around their perimeters. This picture shows one way you ...
0
votes
3answers
74 views

How to create a vector of strings from multi dimensional arrays? [on hold]

The original problem is that I am reading big chunks of binary data from a tool that is being developed. My goal is to read data and parse it to a human readable text such as a .csv file, so I have ...
1
vote
3answers
57 views

Given a 2D character array find all paths from the top left to the the bottom right

Given a 2D character array find all possible paths from the top left corner to the bottom right corner. I have the following recursive solution. Could someone explain how to find the complexity of it? ...