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
Does the ray tracing algorithm involves rasterization of image?
I am working on a ray tracing algorithm , i know that the first step is to develop camera and view plane specifications.
Now is the next step performing rasterization algorithm on image before a BVH ...
1
vote
4answers
40 views
Finding shortest path for equal weighted graph
I have a graph which is of equal weights. How can I find the shortest path?
We can use DijKstra's Algorithm and find the shortest path. I think backtracking will be used in this case. But is there ...
1
vote
0answers
58 views
How to find maximum no. of non-repeating characters in a substring of a given string?
I have a problem which needs to find the maximum number of non-repeating characters in a substring of a given string. I can think of an O(n*n) algorithm which considers all the substrings of a given ...
0
votes
1answer
28 views
Algorithm for Fast Median Update
Suppose that at a point in time, you have a collection of N numbers and know the median element: M. Now, you're given a new value, X, and so you may need to update M. (Or rather, you will need to, ...
0
votes
2answers
36 views
How Can You Clear a Quad Tree Without Recursion ( using queue maybe? )[ANSWERED] (alternate methods welcome)
Ok given a class along the lines of
class quadTree {
short level;
Vec2f midpoint;
quadTree * nodes[4] = { NULL, NULL, NULL, NULL};
public:
void newPartition() {
float j = fWIDTH / 2 ^ level;
...
1
vote
0answers
45 views
Hashing a string between two integers with a good distribution
I'm trying to hash some strings between 0 and a very low n in order to give one color per user.
Here is my (working) code:
function nameToColor(name) {
var colors = ['red', 'blue', ...
1
vote
4answers
84 views
Find the number
This is a problem statement.
Consider a number 2345. If you multiply its digits then you get the number 120. Now if you again multiply digits of 120 then you will get number 0 which is a one digit ...
0
votes
1answer
50 views
Prims Algorithm Node Priority
So I was given this psuedocode for Prims-Algorithm,
INPUT: GRAPH G = (V,E)
OUTPUT: Minimum spanning tree of G
Select arbitrary vertex s that exists within V
Construct an empty tree mst
Construct an ...
2
votes
6answers
72 views
order of an operation when upper bound is fixed
I recently had an interview and was asked to find number of bits in integer supplied. I had something like this:
#include <iostream>
using namespace std;
int givemCountOnes (unsigned int X) {
...
-3
votes
3answers
51 views
Recursive sum to find single digit
I have a number as N=2345
If I sum them the result will be 2+3+4+5 =14;
If I further sum them it will be 1+4 = 5; which is a single digit;
What is the efficient way to find this?
I am following ...
1
vote
1answer
63 views
Is there any better way to find the digit multiplication and summation?
int N = 2345;
var digitArray = N.ToString().ToCharArray();
int multiplicationSum = 1;
foreach (char digit in digitArray)
{
multiplicationSum = ...
1
vote
1answer
48 views
Why is QuickSort Single pivot faster than 3-way partition?
I am trying to roughly benchmark the performance of QuickSorts (Single Pivot, 3-way and Dual Pivot).
Questions 1 :
I am afraid that I am missing something in the implementation of 3-way partition. ...
0
votes
1answer
43 views
Multilateration Algorithm
I'm trying to call upon the famous multilateration algorithm in order to pinpoint a radiation emission source given a set of arrival times for various detectors. I have the necessary data, but I'm ...
2
votes
2answers
46 views
Speeding up a function: checking NA count before computing mean
The function below calculates the mean of a vector. However, it first checks the proportion of NA's present in the vector
and if above a given threshold, returns NA instead of the mean.
My issue ...
-2
votes
1answer
20 views
Machine learning : Algorithm selection
I try to create a machine learning.
The goal of this machine is to give the delay of trains in function of the day of the week, the number of the train,the type of train and some other values ( ...