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.
0
votes
0answers
16 views
Algorithm explanation for common strings
The Problem definition:
Given two strings a and b of equal length, what’s the longest string (S) that can be constructed such that S is a child to both a and b.
String x is said to be a child of ...
0
votes
0answers
7 views
Balancing KD-Tree: Which approach is more efficient?
So I'm trying to balance a set of (Million +) 3D points using a KD tree and I have two ways of doing it:
way 1)
-Use an O(n) algorithm to find the arraysize/2-th largest element along a given axis ...
1
vote
1answer
16 views
Minimum path cover in DAG
I want to know if there exists an efficient algorithm for computing the minimum path-cover in a Directed Acyclic Graph. Please don't confuse the minimum "path-cover" with "vertex-disjoint path-cover". ...
3
votes
1answer
35 views
Generate all base26 triplests in the fastest way
I need to generate a list of triplets containing only uppercase English letters:
["AAA","AAB","AAC", ..., 'ZZZ']
What is the fastest way to do this in python?
-1
votes
0answers
39 views
What is Set Covering in Psychic Modeling? [closed]
I am reading algorithm Design Manual 2nd edition.can some body explain me the war story give in chapter 1 name War Story: Psychic Modeling. Example is in the The Algorithm Design Manual.
4
votes
0answers
83 views
How to simplify a C-style arithmetical expression containing variables during code generation?
I am trying to optimize expression evaluation in a compiler.
The arithmetical expressions are all C-style, and they may contain variables. I hope to simplify the expressions as much as possible.
For ...
1
vote
1answer
40 views
Robot moving in a grid
A robot is located at the top-left corner of a 4x4 grid.
The robot can move either up, down, left, or right, but can not visit the same spot twice.
The robot is trying to reach the bottom-right ...
0
votes
1answer
35 views
How to generate matrices which satisfy some conditions?
Let's consider matrix E = (a_{ij} in Z) where 0 <= a_{ij} <= n (n is a dimension of the matrix E and fixed). Matrix entries a_{ij} satisfy following conditions:
a_{ii} = 0 for all i;
a_{ij} + ...
2
votes
1answer
19 views
Finding the upper (convex) hull in higher dimension (3+)
Sorry for my broken English.
I want to find the lower envelope of a plenty of linear equations.
This is mapped to the problem of finding the upper (convex) hull in its dual plane.
As I surveyed, ...
2
votes
5answers
32 views
Is this worst-case analysis correct for this peice of code?
int a = 0; //1 unit
for (int b = 0; b < N; b++) // (1 + N + N) = 2n + 1
for (int c = b+2; c > 0; c--) //2 + (N+1) + N = 2N+3
a += b*c; //3 units
Yields: 1 + (2n+1)(2n+3) = ...
-4
votes
0answers
29 views
formula to count undirected graph is its connected acyclic subgraph formula
1
B---------------C
/ \ / \
3/ \ 4 4/ \6
/ \ / \
...
2
votes
1answer
57 views
“Charge changing” algorithm
First of all I'm not sure how to name this problem. If anyone have better idea feel free to change it or tell that I do so.
Let's say I have two strings s1, s2 containing '+' and '-', which means ...
0
votes
0answers
33 views
Mapping lat/long to grid
I have a question that I've been googling for a while but haven't found a answer to exactly what I'm trying to do. I hope someone has solved this before and has a quick answer.
I am trying to map a ...
-6
votes
0answers
32 views
Making tarot card game in java [closed]
I would like to make a java game. Specifically a simple tarot card game. There are 21 cards in tarot. Users are addressing a specific question in for themseleves. Tarot is not intended to answer ...
0
votes
1answer
39 views
Make Correspondence between Two different Pointers to the same Class
Suppose I have a city map that I want to make a copy of. The problem is that from and to in the road class are pointers in memory for that particular cityMap object. Making a new object independent of ...