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
13 views
Optimization with a greedy algorithm
If an optimization problem can be solved using the greedy method, is it true that all its optimal solutions must always contain the first choice (i.e. the greedy choice)?
0
votes
1answer
16 views
Big-O between RB Tree and Heap as sorted set
If we construct sorted set based on RB Tree and Heap. Do insertion() and deleteMax() for n times.
(1). What's the Big-O ?
My idea: For both RB tree and heap , deleteMax() and insertion() will all ...
-2
votes
0answers
28 views
Function f(n) neither in O(n) nor Ω(n)
I just got into the Big-Oh and Big-Omega notations. I understand both concepts but I am having trouble with 1 question where I need to find a function f(n) that is neither in O(n) nor in Ω(n). I am ...
0
votes
3answers
55 views
Placing rectangles in another rectangle
I don't know how to properly specify what I want in English, I ask for your help. I need an algorithm to place a number of rectangles into another rectangle like on this site.
Can someone tell me ...
-3
votes
0answers
43 views
Implementing partition method [closed]
I have implemented QuickSort algorithm in Java. But the partition method is giving ArrayIndexOutofBounds Exception. I'm unable to find it. Please help me out. The code I have written has been found to ...
3
votes
2answers
35 views
Clarifying Upper Bounds on Big O notation
I have read quite a bit on the BigO notation and I have a basic understanding.
My question is pretty specific to help my understanding
If I have and array of 100 integers (no duplicates, and randomly ...
-1
votes
2answers
44 views
How to find the combination of words that includes all the letters in the input with Python
I want to find the most efficient way to loop through the combination of letters that are entered in Python and return a set of words whose combination includes all the letters, if feasible.
Example: ...
0
votes
1answer
60 views
How to compute distance of two geographical coordinates?
I read this question and implemented the accepted answer in Python (see below). It works in principle, but the results are consistently about 30% higher than expected (Czech Republic) - is that the ...
-1
votes
0answers
74 views
insertion sort - is my code example correct? [closed]
I just tried to make my own "insertion sort" algorithm using java. It is working and sorting my ArrayList of strings.
I just need to know if it is a correct "insertion sort" algorithm?
public ...
0
votes
1answer
89 views
Storing data from an unknown number of files
I have used the following piece of code to read from multiple .dat files and parse them. This code uses 3D vectors to store data after the reading process. However, I would like that the data ...
1
vote
2answers
43 views
Longest Path in a grid [closed]
Given a grid G.
Each cell can contain numbers [0 - 9] inclusive or an upper case alphabetical letter (say Z);
we can start with the upper left corner.
Then if the cell number we are on is a, we can ...
-1
votes
3answers
43 views
Find root from any node in a BST
How can I find the root of a binary search tree from any given node? More specifically, when should I stop while going through the ancestors from any given node? Is there any function in java to get ...
1
vote
1answer
38 views
Triangulate set of 3D points
I have a set of Points [X, Y, Z]
as an interest points of a 3D Object
and I'm searching for an algorithm that used to convert this points into 3D-Model "Triangulation Algorithm"
I just tried ...
1
vote
1answer
41 views
Find minimum of n Elements with log(n) comparisons per element
I need to write an algorithm that finds the minimum of n elements with:
n-1 comparisons.
Performing only log(n) comparisons per element.
I thought of the selection search algorithm, but I think ...
0
votes
3answers
39 views
Obtain unique/unrepeated values from a List
I have an ArrayList tmp_list which might contain repeated values. I aim to fill an other ArrayList filtered_tmp_list with only one occurence of each value. Here's what I did :
...
0
votes
2answers
49 views
complexity of polygon-construction
I want to proof that the complexity of the problem to construct a simple polygon out of a given set of points (2D) is at least *O(n*logn)*, i.e. every correct algorithm takes at least O(n*logn) steps ...
1
vote
1answer
37 views
Using “Treap” to compare two set
I want to use Treap structure,but I don't familiar with this type of tree well.
I have two set and i want to write a method to compare them with Treap. This method should return a value that show the ...
1
vote
0answers
35 views
Matrix inverse usng linear system solver through cublas , cublasCreate exception or something else
I'm trying to inverse a matrix using linear equation solver through cublas CUDA library.
The original equation is in form of:
Ax = B = I
I - identity matrix
A - The matrix I'm trying to inverse ...
1
vote
3answers
23 views
Finding regions in scattered data
I have a number of scattered data sets in Nx3 matrices, a simple example plotted with scatter3 is shown below (pastebin of the raw values):
Each of my data sets have an arbitrary number of ...
3
votes
2answers
49 views
Finding the radius of an ellipse based on its angle from major or minor axis
I'm doing work with UE3 and am making my HUD. I've done it in canvas, and have a round button - The issue is that on screens that are not square, the button is an ellipse. Hence this leads to issues ...
2
votes
0answers
67 views
Why does my string permutation algorithm only work with 3 or less letters?
The Code:
function recursiveParse(letters, index) {
var i,
index = index || 0;
stringOfLetters = '';
while(index < letters.length) {
stringOfLetters += ...
0
votes
1answer
18 views
How to reverse use a nlp parser to generate sentences
I am trying to develop a Sinhala (My native language) to English translator. Still I am thinking for an approach.
If I however parse a sentence of my language, then can I use that for generating ...
9
votes
2answers
51 views
How to match a tree against a large set of patterns?
I have a potentially infinite set of symbols: A, B, C, ... There is also a distinct special placeholder symbol ? (its meaning will be explained below).
Consider non-empty finite trees such that every ...
-1
votes
1answer
55 views
What algorithms can be used to create a floating layout? [closed]
I am trying to implement a layout system composed of containers which can be set to float both horizontally (left, center, or right) and vertically (top, center, or bottom). Given a set of containers ...
0
votes
0answers
34 views
Find the complexity of longest common subsequence
for(int i = 1; i < str1.length(); i++)
{
for(int j = 1; j < str2.length(); j++)
{
if(str1[i] == str2[j]) c[i][j] = c[i-1][j-1] + 1;
else c[i][j] = max(c[i-1][j], ...
0
votes
1answer
24 views
Trouble understanding formulae describing Markov discrimination algorithm
I've been poring over this paper (http://www.siefkes.net/papers/mrf-spamfiltering.pdf) for more than a few days now, but haven't been able to make sense of any of the formulas in section 3 or after.
...
-2
votes
1answer
87 views
QuickSort algorithm explanation [closed]
Well, i know this is kind of an odd question, but i found this java code for the quicksort algorithm:
private static void quickSort (ArrayList <String> list, int first, int last){
int ...
0
votes
0answers
32 views
Best way to store contacts in Phone
It is basically an Interview question .
What is the best Data-Structure to be employed to store phone-numbers/Contact names in a phone directory . We should be able to retrieve number from name and ...
0
votes
0answers
84 views
How to optimize a function with several variables [closed]
I need to develop code to optimize a set or variables based on the following conditions.
I don't have the source of function.
The function gets a point (x,y) and generate a mapped point (x',y') ...
2
votes
1answer
28 views
Some questions about how ID3 algorithm select the best attribute to branch a node into subtrees
I am studying the ID3 algotithm for an universitary exame and I have some problems to understand how is select the best attribute to create new subtrees having fewer attributes in their root (until ...