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.
2
votes
1answer
17 views
SubArray With Maximum Xor
I have given a Array A i have to find a subarray such that it's xor value is maximum.
I am using Trie.But i getting Time Limit Exceeded Error in some Test Cases.
My Time Complexity is O(N*30*2)
...
1
vote
1answer
15 views
Efficient approximation of nth term without losing accuracy
Probelem Given a recurrence relation for gn as
g0 = c where is a contant double.
gn = f( gn-1 ) , where f is a linear function
then find the value of another recurrence given by
hn = gn/exp(n)
...
2
votes
0answers
13 views
Number of trees that can be formed by deleting nodes in a graph
0
|
0__1__0
| | |
1__1__0
|
1
Let's say I have a undirected graph. We have these conditions:
You are only allowed to delete nodes labeled as '1'.
Deletion of any node must not make the ...
-1
votes
1answer
62 views
finding the value of maximum xor subarray
Given an array of integers (0<= A[i] <= 10^9) and (1<=i<=5*10^5), I'm trying to find the value of maximum xor subrray.
Also, if the value is smaller than the largest element of the array, ...
0
votes
1answer
17 views
QuadTree find neighbor
I'm searching for a algorithm to find neighbors of a quadtree, in the example image, I got the red node, how to find the blue nodes. Any ideas?
0
votes
1answer
47 views
Calculate days between two dates without using any date class
I am trying to right a program for my introduction to java course. The user enters their birthdate in the following format(19900506), the amount of days the person is then displayed. The program uses ...
0
votes
1answer
24 views
What's the difference between Theta(n) and T(n) when considering time complexity?
The professor was discussing the time complexity of merge sort and he divided the whole process into three steps.
check whether the size of array is 1 -> time complexity: theta(1)
He described the ...
0
votes
1answer
24 views
Finding convex hull using gift-wrapping algorithm
Here's the pseudocode for finding convex hull using Gift-Wrapping Algorithm:
Step 1: Given a list of points S, let the points in S be labeled s0, s1,
..., sk. Select the rightmost lowest point S. As ...
0
votes
0answers
47 views
Illuminate all islands with minimum lamps
There are N islands, enumerated from 1 to N. Each of them is so small that we can consider them as points on a plane. We are given the Cartesian coordinates of all islands. X-axis is directed towards ...
4
votes
1answer
46 views
Find largest possible value of S(S=(((min2∧min)⊕(min2∨min))∧(min2⊕min))) where min2 & min are smallest & next smallest integer in k elements of array
There is programming problem on which I am working on. The problem is as:
Given an array A[] of N distinct elements. Let min2 and min be the smallest and the next smallest element in the interval ...
1
vote
3answers
67 views
Algorithm to turn one point into another
You're given as input four integers in the form (a,b) and (c,d).
Determine whether it's possible to get (c,d) from (a,b) if at each step you can choose between the operation (a+b,b) or (a,a+b).
So, ...
-2
votes
0answers
10 views
What specific application best suit for B tree variants like b* (star), b+, prefix b+, and bit tree?
I am trying to compare the four variants of b-tree since I am studying data structure I find it confusing sometimes. Positive response is highly appreciated :). If you can provide the advantages of ...
1
vote
2answers
24 views
remove contiguous subarray to leave the average minimum
This problem appeared in some regional contest for ICPC.
Given n numbers, you have to remove numbers between i to j such that remaining numbers have least average. You can't remove first and last ...
0
votes
2answers
46 views
How to generate Gray codes of n bits that have at max k ones?
I understand Gray codes have one bit change between them and how to convert between binary and gray. But given a bit length of n, I want to generate a series of Gray codes (all possible) that have one ...
-1
votes
2answers
33 views
Convert bool array to int32 ,unsigned int and double?
I've bool arrays of sizes : 32, 48, 64 (each boolean represents a bit). how can I convert them to a number with a good performance( int, unsigned int, double48, double64)?
for example :
bool ar[] = ...
0
votes
0answers
14 views
Computation on large data file without MapReduce.
I have a file containing a million word vector. The dimension of each vector is 300.
For example:
dataFile.txt
word1 [0.1 0.2 0.8 ...... 300th value]
word2 [0.3 0.4 0.6 ...... 300th value]
...
...
2
votes
5answers
78 views
Algo to find duplicates in a very large array
During one of technical interview got this question.
I know way to solve this problem using (in java) HashSet.
But i could not understand when interviewer forced on the word "a very large array let's ...
0
votes
1answer
29 views
Running time for these algorithm [on hold]
I have solved this problem in 3 different ways and I need 3 different run times. O(n), O(nlogn), O(n^2)
The question is - Given an array of unsorted distinct integer n-1 from the range 1 to n, find ...
0
votes
1answer
28 views
How to implement a shortest path algorithm to find shortest route between any two given cities of a graph in python?
I have an input file of the form :
London Birmingham 117
Birmingham Bristol 85
London Oxford 56
San_Francisco San_Jose 50
San_Jose Davis 270
San_Francisco Davis 350
END OF ...
-1
votes
1answer
12 views
When to stop agglomerative hierarchical clustering - stopping criteria
I am coding my application each function so i am not using tools which does everything for you
Been looking for solution when to cut my agglomerative hierarchical clustering
How do i cluster?
I ...
0
votes
1answer
27 views
the concept of Every-case Time complexity
This is a slide from my lecture notes. I understand that if an algorithm's best-case and worst-case complexity are the same then it has "every-case" complexity. However I do not fully understand ...
0
votes
1answer
10 views
Unbalanced binary tree not functioning properly. Node.Js
So I was solving a problem for class involving binary search and the algorithm I implemented to solve it worked fine but my hunch is that a slight gamble would be more effective given the parameters ...
-2
votes
1answer
49 views
how to align decimal points from 2 seperate string
I need to add very big decimal numbers in a form of string, such as
84736362727263737373636366363.82828273737 + 8374646473.838383737377377379:
but first I need to align them. The only thing I ...
1
vote
1answer
25 views
Using Binary Search to find the sub array with the largest sum modulo x, my solution uses iterative search.
I'm working on a hackerrank.com problem. The basic premise is given an array A, and a modulo m, find the subarray B that renders the largest value sum(B)%m. So the sub array that gives the largest sub ...
2
votes
4answers
66 views
Algorithm to find first sequence of integers that sum to certain value
I have a list of numbers and I have a sum value. For instance,
list = [1, 2, 3, 5, 7, 11, 10, 23, 24, 54, 79 ]
sum = 20
I would like to generate a sequence of numbers taken from that list, such ...
0
votes
1answer
26 views
Sorting algorithm for alphanumeric that interprets entire integers instead of characters - Javascript [duplicate]
I need to sort a list that's alphanumeric, but it's botching the multi-digit
integers since it's character-by-character and 1 is less than 8.
Any it's particularly tricky because there can be ...
-1
votes
0answers
17 views
creating a right angled rectangle on google maps from a line
I have an application where the user draws a line, then automatically the software should create a rectangle where the line intersects the midpoint of two adjacent sides of a right angled rectangle. ...
-3
votes
0answers
26 views
How to calculate clustering success - pre assigment true classes are known
I am checking clustering analysis at Wikipedia and can not figure out how to apply techniques to this example
Assume that i have the following manually labelled data-set
Class labels A,B,C,D
...
2
votes
1answer
38 views
Please explain in simple terms why this code fragment has O(n^4) complexity?
Evaluate Big-Oh of the following code fragment:
sum = 0
for( i = 1; i < n; ++i )
for( j = 1; j < i * i; ++j )
if( j % i == 0 )
for( k = 0; k < j; ++k )
...
4
votes
1answer
80 views
Coin Change Algorithm with Dynamic Programming
I am facing difficulty with Dynamic Programming. I was trying the trivial Coin Change problem- COIN CHANGE Problem UVa
I am trying to use top-down approach with memorization but I am getting TLE. ...
-1
votes
1answer
35 views
Reach N^2 in a matrix of size NxN starting from 1 in minimum number of steps
Given a Matrix of Size NxN filled with numbers from 1 to N^2 in random fashion. Our goal is to reach the cell containing N^2 starting from cell containing 1 in minimum number of steps. One can move ...
3
votes
0answers
36 views
Algorithm for offsetting edges of 3D triangle mesh
I have a 3D triangle mesh, and I'm looking for an algorithm to offset all the un-bordered edges border edges of the mesh inwards, along the surface of the triangle mesh.
I've looked at Clipper as ...
0
votes
0answers
22 views
Other than Paxos, what are the primary distributed algorithms used heavily in industry? [on hold]
I just started reading about Distributed Algorithms. A lot of the research in this area appears very theoritical to me. I see some algorithms and variants used in practice, like Paxos/raft being used ...
-1
votes
0answers
14 views
The Levenberg-Marquardt algorithm does not handle bound constraints
I have a very similar case with an optim via lsqnonlin just trying to minimize a price but the lsqncommon is handing over my optim.
lsqnonlin(G, I, lb, ub, options);
with G an function handle ...
0
votes
0answers
23 views
A specific scheduling algorithm
The question I have concerns a hobby project that I'm working on to help out my wife with her work.
I realize that the problem I'm facing is quite similar to what's been answered on SO in numerous ...
0
votes
0answers
34 views
How to get common part of two flat meshes?
I am working on cutting meshes. What am I exactly trying to achieve is that:
Input - two meshes(procedurally generated of course)
Output - three meshes(or more, depends on the given meshes)
A - ...
0
votes
0answers
9 views
What algorithms can be used for product grouping in hierarchy? [on hold]
I've read that usually EAV was flexible, but slow in shopping cart database. I will use PostgreSQL 9.3+ for custom product catalog. I'd like to use table inheritance and I don't mind against periodic ...
-5
votes
0answers
46 views
DNA sequence, what would be an order (n+m) solution algorithm? [on hold]
I wonder if the solution of the problem below could have order O(n+m).
This kind of problems are posted on job interviews, and it would be a bad thing (and waste of time) if no O(n+m) exists:
A DNA ...
0
votes
1answer
62 views
How does battle mechanism of game work? [on hold]
As i proceed towards the end of my gaming project. I am stuck at a part that is commonly known as Battle Mechanism.
What is Battle Mechanism?
Battle mechanism is the algorithm which decides what ...
1
vote
0answers
38 views
Jello effect when displaying a filtered digital signal
I wish to display a mesured signal in real time with some basic filtering (band stop, band pass).
signal is stored in a numpy array (numpy.array)
a matplotlib graph is displaying the numpy array ...
0
votes
1answer
23 views
Check correctness of the algorithm for minimum number of jumps in an array
I have an algorithm that is based on a problem where you need to find the minimum number of jumps to reach the end of the array.This problem was asked in geeks for geeks and they do not have a linear ...
0
votes
1answer
25 views
Optimize an algorithm by removing a td everytime it matches
I have an algorithm that (in Jquery):
Receives a List<string>
Searches a table for a match
Does some action
However I have been told there is a way to do this algorithm and only search ...
0
votes
0answers
28 views
Image Based Visual Servoing algorithm in MATLAB
I was trying to implement the IBVS algorithm (the one explained in the Introduction here in MATLAB myself, but I am facing the following problem : The algorithm seems to work only for the cases that ...
-1
votes
1answer
39 views
Number of binary tree shapes of N nodes are there with height N-1?
How many binary tree shapes of N nodes are there with height N-1?
Also, how would you go about proofing by induction?
So binary tree of height n-1 with node n means all node will have only 1 child, ...
0
votes
0answers
28 views
Finding the depth of every node in a directed cyclic graph
I have a cyclic neural network where i need to find the depth of every node relative to the input nodes where depth is 0. If a path cycles to nodes already visited in the current path, the search ...
-3
votes
3answers
42 views
how to find consecutive composite numbers in R
I want first 'n' consecutive composite numbers
I searched command for finding consecutive composite numbers, but i got the result proving for that thorem. I didn't get any command for that..please ...
-5
votes
1answer
60 views
Boolean variable is automatically changing its value
This problem is from SPOJ. I was required to find whether the graph is Bi-partite or not. I'm using BFS to find it.
The problem here is in a while loop under the section //PROBLEM COMING HERE (please ...
1
vote
1answer
13 views
Listing product with the fixed maximum number of products to display
My app has a feature to list the fixed number of products(say 5) in the screen.
int max=5;
//when the next button is clicked
if(start<=items)
{
start=start+max;
}
//when the previous button is ...
0
votes
1answer
10 views
Running Minimax/Expectimax on the next state chosen
If I run a minimax/expectimax for a current state or the start state, and suppose the root has three children (chance nodes) and runs the minimax/expectimax algorithm. Suppose, it finds the optimal ...
-6
votes
0answers
22 views
What is every case time complexity\ [on hold]
I need help in determining what is every case time complexity and not an every case time complexity with examples. I have knowledge on what average, worst and best time complexity is.