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.

learn more… | top users | synonyms (2)

1
vote
0answers
26 views

Minimum removed nodes required to cut path from A to B algorithm in Python

I am trying to solve a problem related to graph theory but can't seem to remember/find/understand the proper/best approach so I figured I'd ask the experts... I have a list of paths from two nodes (1 ...
0
votes
1answer
21 views

Finding the number of arrangement of N people of different height such that K of them are visible from front

How to find the number of ways in which N people of different heights (possibly some have same height) are arranged in a queue such that atmost K are visible when seen from front of the queue. If a ...
2
votes
1answer
39 views

Counting how many different primes are in the factorization of N

I am stuck for a longer time than I'd like to admit in project Euler number 47. I can definitely solve the problem, but my algorithm is too slow. It works when I find the three consecutive numbers ...
0
votes
2answers
14 views

Algorithm analysis nested if

I am working on figuring out big O notation for algorithms and I was wondering if I have this down correctly. I am currently analyzing the following code: int expon(int x, int n) /* n > 0 */ { ...
0
votes
1answer
19 views

How to save the steps the algorithm takes to order an array?

Im currently trying to develop a program in Java that has to print the steps an algorithm takes to order the elements in an array (all the elements in the array each time it changes), where print ...
2
votes
0answers
25 views

Simulation and Ad-Hoc Optimization Algorithm

There are mirrors in a rectangular field measuring N by M squares (1 <= N, M <= 1,000). In each square, there are double sided mirror between two opposite corners. These two possible ...
2
votes
0answers
10 views

MathML generation algorithm for Javascript. Any recommended references

I am trying to build MathML from Math equation. I am using JavaScript for coding. Are there any references or recommended readings I can go through to get a grasp of required algorithm? I am reading ...
0
votes
0answers
18 views

Count down game in OCaml

This is a quite typical game. You are given a list of integers, together with a value. You use parenthesis, +, -, *, / to get to closest to the given value. It is not necessary that all integers ...
0
votes
0answers
7 views

Creating Data “Tiles” for Massive Amounts of Price Data

I'm designing a JavaScript chart that I want to be awesome and I need your help. Let's say I have 5 million records with price data like this: open high low close volume timeStart timeEnd ...
2
votes
1answer
50 views

Given an array of +ve integers, Find the number which occurs odd number of times in O(n) time & constant space.

Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space. int ...
0
votes
2answers
30 views

find the indices of pairs whose sum is x

Given an array, I have to find the index of pairs whose sum is equal to x. Suppose the array is arr[5] = 1 2 3 4 2 and sum = 5. then the pairs are (1,4), (2,3) and (3,2). I need to store indices of ...
0
votes
1answer
41 views

Printing subsets that sum to a target in C++

I am trying to implement an algorithm that prints subsets of an array that sums to a target in C++. I got the algorithm from the internet and implemented it in C++. Can somebody please find out why I ...
0
votes
0answers
21 views

Rendering smooth terrain with cubic bezier splines?

I'm trying to make a mountain landscape with bezier patches. I have it such that it ensures C1-continuity, but it just does not work out. What I have as input to the function, although it being ...
2
votes
4answers
77 views

Minimal number of adjacent swaps?

There are N characters of types A and B in the array (same amount of each type). What is the minimal number of swaps to make sure that no two adjacent chars are same if we can only swap two adjacent ...
1
vote
1answer
26 views

Finding shortest path distances from a given node s to ALL the nodes in V in a graph with two negative edges

I have a follow-up question on this: Finding shortest path distances in a graph containing at most two negative edges Ranveer's solution looks great, but it is not fast enough because I need O(|E| + ...

15 30 50 per page