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.
0
votes
0answers
6 views
algorithm analysis of weighted quick union with path compression says running time will be “linear” in the real world, how?
I am undertaking the algorithms course on Coursera, there is a section where the author mentions the following
the running time of weighted quick union with path compression is
going be linear ...
0
votes
0answers
8 views
Error-correction code for transmission only with bit-flipping from 0 to 1
I am using a transmission system that uses a Bloom filter (this part is out of my control). I want to send a small amount of data (32 bits) using this system.
For each bit [0,31], I add its index to ...
-4
votes
1answer
36 views
Dijkstra's Algorithm pseudocode explanation
I am trying to implement Dijkstra's algorithm using PHP to find the shortest path from the source to all possible destinations. From the research that I have done, the best and most simple looking ...
-2
votes
1answer
26 views
Examples of puzzles
So, an example of PUZZLE which its time complexity is linear is the problem of searching for a specific value in an array: it is easy to prove you can't do it with less than n comparsions, and we have ...
2
votes
2answers
29 views
Get rectangles from a 2d array of tiles
I basically want to convert this input:
var tiles:Array = new Array();
tiles[0] = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0];
tiles[1] = [1, 1, 1, 1, 0, 1, 1, 1, 0, 0];
tiles[2] = [0, 0, 0, 0, 0, 1, 0, 0, 0, ...
0
votes
0answers
13 views
Convert Eular Angles from World Axises to Local
I am trying to create a VR application using iPhone's motion manager object. By VR I mean an app to show places on camera.
I can successfully visualize iPhone orientation using yaw, pitch and roll ...
0
votes
2answers
27 views
Calculate elements in a array that are linear
I have a large array of a tuple (data, time)
Part of the array contains data that has a linear slope.
Other data in the array is non-linear.
What algorithm can I use to determine
Where does the ...
0
votes
0answers
36 views
Median of Medians Algorithm: What should I do, after sort each 5-element slot?
Median of Medians Algorithm: What should I do, after sort each 5-element slot?
EDITED
Note:
I just want to find the "median of medians"(not true median).
I will use this "median of medians" as ...
0
votes
1answer
39 views
Graham scan issue at high amount of points
I have an issue in graham scan algorithm when my list have a lot of points, but works every time fine with low amount of points. I made some screenshots :
working : (300 points)
Link to picture : ...
1
vote
1answer
23 views
Extracting and joining strings with boost::algorithms::join
I have a collection of a certain struct, and I want to join a string member of each of these structs into a semicolon-separated list. Making good use of the standard algorithms library and Boost, the ...
0
votes
2answers
46 views
Clearing Test Cases of a competitive alogithm
I am stuck in clearing all the test cases for a simple algorithm and I am looking for the reasons or the modifications that I should be doing in my code. Here, there is an inline link to the question.
...
-2
votes
1answer
38 views
Range search in quadtree efficiency
I have an implementation of a point quadtree and rangesearch of that tree in C. My rangesearch returns the correct result but when I run it through valgrind, valgrind gets killed. I am using a ...
-1
votes
0answers
29 views
Image comparation algorithm
I'm trying to write my own simple image comparator. It works by next algorithm (here just a generalization):
1) Set two variables: parts and accuracy
2) Open two images
3) Calculate average colors ...
0
votes
1answer
81 views
What's wrong this use of sort function in C++11?
I made this program for taking in input in two vectors ( long long int considering the fact that the numbers can be really large that a normal int cannot accomodate ) and then I wish to sort them.
...
2
votes
2answers
74 views
Why is this the cost?
The algorithm of the Quicksort is:
Quicksort(A,p,r)
if p<r then
q<- partition(A,p,r)
Quicksort(A,p,q-1)
Quicksort(A,q+1,r)
According to my notes,the cost of ...
1
vote
2answers
101 views
how to fit polygon inside another polygon [on hold]
I have two polygons as shown in the image below.
The left one is "rough polygon" and the right one is "final polygon"
Now, I'm looking for algorithm to fit "final polygon" inside "rough polygon" ...
0
votes
1answer
47 views
Inserting in order (linked list C) error
I wrote the function below to insert a value in order into the linked list, using a cmp function defined by the user. So i tested this out, I wrote my own cmp function for integers, and put in the ...
1
vote
1answer
34 views
Maximizing profits for given stock quotes and volumes
Given an array of stock quotes Q[0], ..., Q[n-1] in chronological order and corresponding volumes V[0], ..., V[n-1] as numbers of shares, how can you find the optimal times and volumes to buy or sell ...
1
vote
1answer
31 views
Compute delta of 2 list of integers
I have 2 maps of : map1 and map2.
where the string is a key, and the value is the number of occurrences of that key.
I want to compare the 'delta' between the maps,i.e. I want to know how far is one ...
0
votes
0answers
38 views
Determine exponential time complexity [duplicate]
I've gotten pretty good at figuring out time complexity, but am still confused about how to determine exponential time algorithms. The algorithm below has a worst case running time O(k^n). How did ...
-2
votes
1answer
21 views
Create a web page with content corresponding with another page?
I'm trying to create a web application with 2 pages video page and picture page. After watch video user will be redirected to picture page The requirements are :
Video page show video on lists ...
-5
votes
0answers
68 views
Having trouble solving following algorithmic task [on hold]
The question is as follow--
A string contains only 0's and 1's(any number of 0's and 1's)
Given n(only length of the string,not the string itself) find how many permutations of string are possible ...
-2
votes
0answers
23 views
need help in access database (VBA)
I created an access database, I have 2 tables (sales table and stock table) and from that I created 2 forms (sales form and stock form)
In simple, when a sales is made from the sales form I need a ...
5
votes
4answers
125 views
Order (a,b) pairs by result of a*b
I would like to find the highest value m = a*b that satisfies some condition C(m), where
1 <= a <= b <= 1,000,000.
In order to do that, I'd like to iterate all pairs of a,b in decreasing ...
0
votes
3answers
23 views
How to add mouse event in drawn canvas compoent
I want to draw 200 or more(highly fluid) object in canvas.
and add mouse over, mouse click event each of them.
source code like this...
(valiable k is increase)
'
....
....
...
0
votes
2answers
58 views
From a set of pairs, find all subsets s.t. no pair in the subset shares any element with a pair not in the subset
I have a set of pairs. Each pair is represented as [i,1:2]. That is, the ith pair are the numbers in the first and second column in the ith row.
I need to sort these pairs into distinct groups, s.t. ...
0
votes
2answers
42 views
Where's the mistake in my Spiral Matrix algorithm? Size of matrix = input N^2
So I'm creating a spiral matrix using C#.
A spiral array is a square arrangement of the first N^2 natural numbers, where the numbers increase sequentially as you go around the edges of the array ...
2
votes
3answers
139 views
How to make this algorithm faster? [on hold]
I am trying to come up with the following algorithm:
The input is unsigned integer number.
The output is the size of the array of unordered pairs of unsigned integers, which, when multiplied, give a ...
3
votes
3answers
57 views
How May One Represent Magic The Gathering Casting Costs Programmatically? [on hold]
For those who are unfamiliar with Magic (as it's often called informally), casting costs are values that represent the "mana" needed to cast a "spell". Mana comes from different sources, and has ...
0
votes
1answer
35 views
Is it a convention that the distance of a vertex to itself is 1?
I was reading this file, and on the 27th page, it has a pseudo code about determining if a vertex is a articulation point in a network.
In the code, the count is increased before it is saved in the d ...
0
votes
0answers
43 views
Which Data structure should I use for Data mining algorithm
I have to implement two Interaction pattern algorithms (IPM and IPM2) , I'm currently halfway through my first algorithm. Unfortunately,I am new in data mining and I don't know appropriate data ...
0
votes
0answers
8 views
How do I generate an XML SignatureValue
I am attempting to sign a soap request. The rest of the document is valid, but the SignatureValue I end up with is not what is expected. I learned Soap and signing over the past few days, so the most ...
4
votes
1answer
50 views
How can I calculate the point between two overlapping linear datasets?
I have two sets of data that overlap a bit (see plot below). I need to find the point between these sets where one would guess an unknown data point would belong in a particular category.
If I have a ...
1
vote
0answers
74 views
What's time complexity of this algorithm for generating all possible valid parentheses?
Generate Parentheses Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
For example, given n = 3, a solution set is:
"((()))", ...
2
votes
5answers
81 views
Random number generation with next and previous support?
How to write two functions for generating random numbers that supporting next and previous?
I mean how to write two functions: next_number() and previous_number(), that next_number() function ...
0
votes
2answers
79 views
Dynamic Programming - Word Break
I am trying to solve this Problem.The question is as follows
Given an input string and a dictionary of words, find out if the input string can be segmented into a space-separated sequence of ...
-1
votes
0answers
53 views
Finding longest continous subarray [duplicate]
I have a string like : #####** . I want to Find longest contiguous sub array that will contain equal no. of stars '*' and hashes '#'.
What I thought :
assign +1 to stars, and -1 to hashes.
...
-3
votes
0answers
23 views
Finding the Max. Damage [on hold]
Problem Statement
manager a and manager b are managers of wrestling teams A and B resp. You are given arrays powerB[] and countB[] where it denotes that team B has countB[i] players of power ...
0
votes
1answer
49 views
I want to finish this sorting technique
How would I start to code this sorting technique ( I changed it from algorithm because it is not efficient to really make a code that can do this. It is only for knowledge purposes) to do this ...
0
votes
3answers
48 views
Rotate left side
I have an integer.
Suppose n=25314;
I want to rotate the digits on the left side of an integer(n) n times.
For ex. int=25314 and 3 time rotate left side .so, result is int=14253
int =32546 and 4 time ...
0
votes
2answers
53 views
Position of object with n known points and distances
I'm doing some work with triangulating the position of a receiver based on its distance to known points in space. I basically get a set of distances D[N] from the nearby broadcast points, and have a ...
0
votes
0answers
60 views
c# permutation without repetition when order is important [duplicate]
I want to get the permutations from a List of strings without repetition. I have a working code for that:
static IEnumerable<IEnumerable<T>> GetPermutations<T>(IEnumerable<T> ...
0
votes
1answer
42 views
Time attendance algorithm
I've recently started to work on Time attendance software. People are using cards to check in and check out, but sometimes they check out before they check in and then some of them realize they made ...
1
vote
2answers
118 views
Finding the time complexity of code
Given is an infinite sorted array containing only numbers 0 and 1. Find the transition point efficiently.
For example : 00000000000111111111111111
Output : 11 which is the index where the transition ...
-3
votes
0answers
37 views
Are regular expressions over-used [on hold]
I have a feeling people use regular expression more than they are supposed to. Don't get me wrong, I use regular expression quite often, but I try to avoid them as much as possible.
for (most) of ...
-2
votes
1answer
36 views
Cycle detected while printing root to leaves path
I used the solution to this problem to print all root to leaves path for a n-ary tree I have.
Unfortunately, I suspect, there is a cycle in one of the branch of the tree due to which the program ...
3
votes
1answer
47 views
Non-Dominated Rank based Sorting Genetic Algorithm Elitism Issue
I am trying to implement a genetic algorithm for my Master's Thesis relating to satellite constellation design. I want to obtain pareto-fronts for multiple objective functions. I am writing my own ...
0
votes
5answers
67 views
Tricky time complexity
I've gotten pretty good at figuring out time complexity, but am still confused about how to determine exponential time algorithms. The algorithm below has a worst case running time O(k^n). How did ...
1
vote
2answers
126 views
What is the difference between this C++ code and this Python code?
Answer
Thanks to @TheDark for spotting the overflow. The new C++ solution is pretty freakin' funny, too. It's extremely redundant:
if(2*i > n && 2*i > i)
replaced the old line of ...
3
votes
2answers
90 views
Best approach to solve Word Chain
I am trying to solve this problem in CodeEval.
In this challenge we suggest you to play in the known game "Word
chain" in which players come up with words that begin with the letter
that the ...