Tagged Questions
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.
1
vote
0answers
11 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 ...
-1
votes
2answers
42 views
How can I flatten a multi dimensional array?
I am reading raw data as a multi-dimensional array of Integers or floats or any other number. The size of the array is given to me as an array of integers. There is no limit to the size, so the given ...
0
votes
1answer
22 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? ...
0
votes
2answers
36 views
Data Structure for keeping frequency count of pairwise data?
I have a table with hundred' of record where a field is paired with a similar field based on an id. I want to know what is a good data structure for keeping frequency counts for the number of times a ...
2
votes
2answers
59 views
How do I implement this “color difference” algorithm?
As a follow up to this question: (How can I draw legible text on a bitmap (Winforms)?), I'm drawing legible but small text on top of a bitmap by calculating the "average" color beneath the text, and ...
1
vote
1answer
32 views
C - Swapping nodes in a linked list with a sorting algorithm
Im working on a project for school in which I need to sort a linked list with any sorting algorithm (preferably bubble) - please note that swapping each node data is not allowd as I am expected to ...
-1
votes
0answers
15 views
MacBook Pro for CS major [on hold]
I will be a Computer Science major this fall. I need a laptop and I was looking at the MacBook Pro with a dual core i5, 8GB RAM, Intel Iris graphics and a 13.3" Retina display. I am interested in ...
0
votes
0answers
36 views
Print all palindromes of size greater than equal to 3 of a given string
I have written the which works fine.
public class Palindrom {
public static boolean isPalindrom(String s){
char[] c = s.toCharArray();
for(int i ...
0
votes
1answer
33 views
Time complexity of sorting a list in descending order.
I have a list of pair of variables along with their correlation value stored in a database.
var1 var2 corr
My algorithm involves sorting the list in descending order (based on correlation ...
3
votes
0answers
70 views
Shanks algorithm fails mysteriously on a certain set of numbers
I am trying to implement Shank's Algorithm to find discrete logarithms. I implemented it in Java and it works…most of the time. For some reason, I find that on one of the times I try to use it, it ...
0
votes
0answers
27 views
Scalding: How to reduce in-memory computations on lists?
With Scalding I try to find edit-distances between pairs of similar strings. All in all I have 10 000 000 strings in a CSV file. To reduce computations I use the following algorithm:
Split all ...
1
vote
2answers
46 views
Can adding data to a file compress it by more?
Let's say I have a 10MB file that I can compress to 5MB. Are there situations where you could add data to the file and cause it to compress to smaller than 5MB?
Edit: And just to be clear by adding ...
0
votes
1answer
38 views
same algorithm execution time on different computers? [on hold]
if an algorithm with O(nlogn) time complexity is executed in two seconds on a computer ,how long does it take a 100 times faster computer to execute the same algorithm? is it 2/100 seconds? as far as ...
1
vote
0answers
11 views
Setting default diff algorithm does not translate to default merge algorithm (patience)
I've seen many blog posts and stack overflow posts say that
git config --global diff.algorithm patience
will allow both diffs and merges to use the patience strategy option with the default recursive ...
0
votes
1answer
46 views
Parts Moving Through Tanks. Shortest Path Algorithm
Suppose there is a production line with 8 tanks: each filled with a different substance for parts to be dipped in. The parts will be dropped into tanks by a crane along side the tanks. Each part ...
0
votes
0answers
12 views
Comparing similarity of two bitvectors or fingerprints
I have a question that's two part.
1) The first part is that I have a bit vector or a fingerprint of a digital circuit where the each bit is high if a specific structure or component exists and zero ...
0
votes
0answers
21 views
Sorting 3D points for
Given a set of points in 3D space, which belong to the borders of a surface, does exist any algorithm to sort them in order to reconstruct the polygon? At the moment I use a "minimum distance" ...
1
vote
1answer
33 views
Reconstruction a signal from random samples with holes
I've encountered the following problem as part of my master thesis, and having been unable to find a suitable solution over the last few weeks I will ask the masses.
The problem 1
Assume there exist ...
0
votes
0answers
39 views
Best approach to update page views of millions of rows in MySql
Scenario
I have a database of over 2.5 Million Videos and Viewed daily over a million times (total). In my case I am storing all events in NoSQL (mongodb) and then process it to generate a ...
0
votes
1answer
76 views
Efficient algorithm for finding number of almost sorted intervals
In a problem, I have to find the number of consecutive sub sequences of an array which have the following conditions satisfied(They are called almost sorted intervals)
The first number in the ...
0
votes
0answers
49 views
about ε “Differential privacy” [on hold]
As a beginner researcher in "Differential privacy" (I'm focused on applying to Datamining algorithms), I have a question which puzzled me for a while, that is just a inequation described in the ...
2
votes
1answer
39 views
Understanding the input of the lazy quicksort presented in The Joy of Clojure
I copied the lazy quicksort implementation from The Joy of Clojure
and added two println statements after the loop, to better understand how the input works (see implementation at the bottom).
When ...
0
votes
0answers
24 views
How to construct a finite automaton for searching two patterns P1 and P2?
Here is the question of CLRS 32.3-4
Given two patterns P1 and P2 , describe how to construct a finite automaton that
determines all occurrences of either pattern. Try to minimize the number of ...
0
votes
2answers
46 views
Efficient algorithm to print all subsets of length k in an array of n elements
This is a very classic problem and most of the solutions I found use the recursion approach like this. Since there are Cn,k combinations, I was wondering if there exists an algorithm that can print ...
4
votes
1answer
68 views
Solving planning problems
I'm new to the AI/ algorithm field and is currently trying to solve a problem, I've so far only implemented an A* path finding on a 2d grid array before.
The problem goes like this:
Consider a class ...
0
votes
0answers
22 views
Sync files between two computers [on hold]
How can I automatic synchronize files between two computers ? By don't broadcast like bitsync, I just want to sync specific IP between two computers.
Please help, thank.
1
vote
1answer
41 views
Algorithm X to Solve the Exact Cover: Fat Matrices
As I was reading about Knuth's Algorithm X to solve the exact cover problem, I thought of an edge case that I wanted some clarification on.
Here are my assumptions:
Given a matrix A, Algorithm X's ...
1
vote
1answer
19 views
How are filled paths rendered?
What are the standard algorithms used in vector graphics for rendering filled paths?
I'm not only interested in the process of rendering strokes, I also would like to know how the shapes are filled - ...
0
votes
2answers
42 views
Is lossy compression just downsizing?
I am interested in learning about compression and pixelation detection algorithms. While scouring the web I stumbled across downsizing and was wondering if that is all that lossy compression ...
0
votes
1answer
27 views
Return all possible combinations when selecting a single item from multiple bins, with an IF condition
If I need all combinations possible when selecting an element from N different bins I can do:
all_possible_cominations = [selection for selection in itertools.product(bin1,bin2,bin3...)]
But in ...
2
votes
2answers
68 views
common overlap of N circles
Having N circles represented by their radius and center coordinates , I wanted to know if there exists an algorithm for finding whether or not the point P exists such that P is inside all of the ...
0
votes
1answer
71 views
Binary Search, Speed up using a nearby index
When doing multiple binary searches on a large set of data, Searched on nearby values could be used to reduce the size of the search.
For a simple example, lets say we're searching a range...
for k ...
0
votes
1answer
9 views
Discarding elements outside viewport
My setup allows me to add elements to some arbitrary world space. An element has a (x,y) coord as well as some width and height.
I then render a sub-section of that world using a viewport/camera. ...
0
votes
2answers
25 views
Determine if an Rectangle closer to an Circle than another Rectangle
Suppose we have two rectangles A, B and a circle R, and we would like to determine if for any point r \in R, a \in A, b \in B, "dist(r, a) < dist(r, b)" always holds, where dist() returns the ...
0
votes
0answers
51 views
Solve the recurrence T(n) = nT(n-1) + n, T(1) = 0 [on hold]
I have tried to solve the recurrence: T(n) = nT(n-1) + n, T(1) = 0, but I haven't have success so far. I guess that the answer is T(n) = n! or T(n) = n^2, but I don't know how to get to these ...
4
votes
4answers
81 views
How to make a permutation that tailors output efficiently
This was an interview question, which I failed to answer, but am still curious about how to solve.
You have big family of N persons, 1, 2, 3, ..., N years old respectively.
You want to take a picture ...
0
votes
2answers
42 views
Looking for an algorithm for an efficient itinerary
Am wanting to write an app that helps say a travelling salesman / musician plan their tour.
So this is about making an efficient itinerary.
So they would put in their start and end points and the ...
0
votes
3answers
45 views
Java code to delete whole Binary tree.
I read a postorder traversal application to delete a binary tree and a code which is written in c++.
I am wondering how to write this code for java. I think we have to set the node as null in ...
-4
votes
2answers
57 views
what is the best-case / worst-case analysis for the following loop? [on hold]
no steps are skipped from the outer loop and the second loop which would give us n(n+1)/2 iterations, but i don't know how to compute the innermost loops.
int n = int.Parse(Console.ReadLine());
int i ...
4
votes
5answers
48 views
How to calculate running time of algorithm [on hold]
I am trying to improve my knowledge in Algorithms and I was wondering if someone can give me a good explanation on how to easily calculate running time.
boolean hasDuplicate(int[] array) {
for ...
1
vote
1answer
48 views
Sudoku Algorithm generates 0 values
So I have a sudoku algorithm for a generating a completed game board. The problem is that the algorithm in some instances runs out of possible values to place in the grid, so by default it places a 0.
...
0
votes
0answers
34 views
How to decode multiple-digit gamma codes and get the gap sequence? [migrated]
How to decode gamma code:
1110001110101011111101101111011
and get the gap sequence?
Detailed information about Gamma codes with brief example of decoding can be found here.
But in their example ...
3
votes
2answers
82 views
Triangulation 3D algorithm
I have thousands of polygon on 3D space which contains more than 3 vertex. I want partition each polygon into a set of triangles. I have been looking all over the internet and I can not find any ...
0
votes
0answers
50 views
Python vs. Javascript speed difference [on hold]
I solved the same Project Euler problem using Javascript and Python. Both solutions essentially use the same logic. The Javascript solution is MUCH faster when I run it in my terminal using node. How ...
2
votes
2answers
41 views
Firebase: How to match opponents in a game?
I'm implementing a social chess game. Every user can create a new game, and they'll wait until the system will find an opponent for them.
When user creates a game, they specify constraints: color ...
0
votes
1answer
46 views
How to implement Merge sort starting from 0?
I'm reading Introduction to algorithms - Third edition and I'm stuck in the Merge-sort problem. I want to implement the algorithm on C#. As we know, or not, nevermind, structures in the book are ...
-1
votes
0answers
62 views
bitwise & of any two elements of array such that it is maximum
I'm solving codechef problem TAAND (www.codechef.com/problems/TAAND)
My approach is
1) I've created a trie data structure for storing the elements of array in binary format
2) whenever a new ...
1
vote
1answer
69 views
Whats the best data structure/algorithm for compressing a 2D curve?
I'm looking to make a recursive function that reduces the data points on an amplitude/time graph, whilst preserving the features of the curve. I was initially thinking that I'd just use a loop, here ...
5
votes
1answer
92 views
How to order a collection with PartialOrdering?
I need to order a collection of envelopes. Each envelope is described with its height and width. Envelope1 is smaller than envelope2 if it can be inserted in envelope2. If envelope1 cannot be inserted ...
-1
votes
1answer
41 views
Check positive linear combination of 2 dimensional vectors [on hold]
I have three vectors in the plane and I want to check if the third is a positive linear combination of the other two as fast as possible.
that is if y = ax + bz, I want to check if both a and b are ...