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
10 views
what is the solution of this recurrence equation also suggest the approach :
How to solve the following recurrence equation?
I tried to solve by taking n = log k but couldn't meet the solution
T(2^n) = T(2 ^(n/2)) + log n
-2
votes
1answer
50 views
Sum of prime numbers less than 2 million [duplicate]
I am trying to solve a Project Euler problem, it wants me to find the sum of prime numbers below 2 million. Here is the code I wrote :
#include <iostream>
using namespace std;
bool isPrime ...
0
votes
0answers
29 views
medians of medians algorithm, implementation issues?
As a part of median of median algorithm, I have to partition an array based on a given element of the array. Please find the entire code below. I am having some issues with the code as it doesn't give ...
-1
votes
2answers
27 views
Algorithm to represent a sequence of numbers
I have a sequence of numbers and I want to write it using a algorithm (iterative or recursive, doesn't matter).
Contextualizing: This numbers are indexes to iterative over a list of lists. I need to ...
2
votes
6answers
70 views
Check if all the array members have the same value
Is there an STL algorithm or fast technique to test if all the members of an array are set to the same value?
For example, I have an array with default values:
bool *finishFlags =new (std::nothrow) ...
0
votes
4answers
52 views
Sum of all digits for a given Positive Number of type long in Java
I was wondering why the following code solutions based on the modulo operation do not work when moving from the int type to the long type.
For example given 111111111111L I would like to get returned ...
0
votes
0answers
10 views
karger's algorithm: merge vertices not edges
Karger's Algorithm is a randomized algorithm to find the global min cut. It works by contracting edges (i.e., two vertices that are connected by an edge become one and the edges are updated ...
0
votes
3answers
54 views
Sort numbers (underscore)
I am trying to fix my last problem and still, I cannot figure out how to solve it. My task was to write a program which sort numbers, but: our tutor gives us some extra points for program dealing with ...
0
votes
1answer
26 views
Finding Cycles in Graphs Using Depth-First Search
Given the following depth-first search, why does the check if(Parent[currVertex] != successorVertex) in ProcessEdge method detect a cycle? This code follows the algorithm given in the book Algortim ...
3
votes
3answers
54 views
Print the values of (3^i *7^j) in increasing order and in optimal way
I encountered an interview questions which asks you to print the value of 3i * 7j in increasing order but in optimal way.e.g.
30 * 70 = 1
31 * 70 = 3
30 * 71 = 7
32 * 70 = 9
31 * 71 = ...
1
vote
1answer
26 views
What's wrong with this implementation of Tarjan's algorithm?
I've implement Tarjan's algorithm following the Wikipedia's article however I'm experiencing a problem. What I'm trying to do is to find all strongly connected components with size greater than 1.
...
0
votes
0answers
7 views
Estimating parameters of survival mixture model with one covariate using EM algorithm
I have generated data for survival mixture model with two components (e.g. Weibull-Weibull, and Weibull- Gamma) and used EM Algorithm scheme to estimate the parameters in R Lang., and it worked fine. ...
0
votes
1answer
40 views
Bulk containment queries
I have a convex shape defined by a set of vertices. I also have a large set of points and I would like to test which are contained in the convex shape. Currently I just use an open source linear ...
0
votes
1answer
18 views
Javascript convert table header having multiple rows to divs
I am looking for an algorithm in javascript language that will read a table header and then return equivalent DIVs in either a string OR as an object of DOM. The header looks like this:
HTML:
...
-7
votes
0answers
24 views
Solve English peg solitaire with backtracking
English peg solitare is a puzzle where the board has the form of a cross. It consists of 32 fields. 31 of these fields contain a peg. The single field in the middle of the board is empty. (We mark a ...