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)

-2
votes
1answer
17 views

Interview preparation [on hold]

I have an interview in 2 weeks from now for 3 hours long , with 2 yrs of experience as .net developer i am not aware of data structures and algorithms , wondering what is the best way to start or book ...
0
votes
0answers
12 views

Random number distribution generator with a guaranteed sum over a given number of iterations

I'm trying to write an algorithm that will generate a distribution of numbers that will sum to a defined value and will do it all in a given number of iterations. This is what I've come up with in ...
0
votes
0answers
7 views

RUN TIME ERROR in quick sort algorithm

I'm trying to implement quick sort algorithm on an array. I'm having some doubts about the partition function written in my code.Also when I execute this code compiler outputs your code doesn't print ...
0
votes
0answers
8 views

How do path compression and union by rank complement each other?

I have been reading about union-find problem. The two main improvements are path compression and union by rank. As far as I understand union by rank is used to determine how to combine disjoint trees. ...
1
vote
1answer
33 views

Removing duplicates without Linq for IList of IList

What is the most efficient way to remove duplicates in an IList in C# without Linq I have the following code from another SO [1], IList<IList<int>> output = new List<IList<int>...
2
votes
1answer
35 views

Cracking the Coding Interview: Why does the recursive subset algorithm increase the index rather than decreasing it?

In chapter 8 of Cracking the Coding Interview, 6th Edition, there's a question for finding all the subsets, and this is the given solution: Arraylist<Arraylist<Integer>> getSubsets(...
1
vote
2answers
16 views

Algorithm to connect multiple points without inclusion

I am searching for an algorithm to connect multiple points without including one of the points. The requirement is that all points are connected but no points are in the interior of the resulting ...
0
votes
1answer
16 views

Algorithms for Search tree vs building tree

say I want to have an algorithm which gets a solution as quick as possible, which consists of starting from a state in a tree, and going through all possible states in a tree-like strucutre, why would ...
0
votes
0answers
4 views

Fast axis-aligned bbox and cylinder/cuboid intersection

I need to efficiently cast a beam (either cylindrical or cuboid) through a regular 3D grid of cells (voxels) and mark the cells that get visited by the beam. The beam is defined either as a bottom/...
0
votes
0answers
24 views

Display maximum military time from given four integers

I encountered this question in one of the interview challenges. The question was that given four integers, display the maximum time possible in 24 hour format HH:MM. For example, if you are give A = ...
0
votes
0answers
25 views

How to find the minimum number of operations to change a string of bits to another?

Could someone explain me an algorithm to solve the following problem: I have been given two random bit strings of length n. I have also been given fixed m operations. Each operation changes some ...
-1
votes
2answers
27 views

how to add the value of each array with - instead of , javascript

New to javascript. below is my code, below that is what the algorithm is suppose to accomplish. function creditSum(arr) { var num_of_elements = parseInt(arr) array = arr.toString().split() ...
-2
votes
0answers
17 views

Division on 2 point on elliptic curve

How to divide Point(X1,Y1) on 2. Point on elliptic curve: y^2 = x^3 + A * x + B A = 0 B = 7 Please, tell the method. Here is how to double Point. The question is how to divide Point on 2. Here ...
-1
votes
1answer
13 views

How to solve simultaneous equation with Qbasic

Solving x= 4y + 3 while y= x - 9 with BASIC programing language.
0
votes
0answers
6 views

MongoDB schema nested, is it the right way?

I would like to know if the below nested bson is the right way to do for a project. There is a root directory. The root directory can have as many folders as the user wants. Each folder can have as ...
-2
votes
0answers
19 views

Finding the worse-case runtime of a function

Here's an example of what I'm talking about. I'm sorry to be that guy, but I seriously do not understand where to go with this. Any hints or steps would be greatly appreciated. I really want to know ...
3
votes
1answer
47 views

Maximising stock profit given multiple stocks [on hold]

I have looked into stock profit maximising algorithms depending on the situation. Strategies for situations where you only have one stock and can either buy/sell once or multiple times are clear to ...
0
votes
3answers
60 views

Writing a generic function for minimum element in arrays of integers and characters(strings) in C

I am trying to write a generic function to obtain the minimum element in an array of integers or strings. I am using memory functions to do so. The following is the code which I wrote: Edit: Modified ...
0
votes
0answers
26 views

assertArrayEquals for an error output [duplicate]

I have created a generic swapping algorithm. In order to for this an array is required and the elements are swapped using integer indices. I have created a JUnit test class for this and cannot ...
1
vote
1answer
30 views

Evaluate a ranking algorithm [on hold]

I'm working on an algorithm to rank nodes in a directed graph. My goal is to detect the most important node bases on its centricity on the graph. My problem is: How to evaluate and judge the ...
-1
votes
1answer
63 views

Euler Tour in C#

I am wondering what is wrong in the below C# code to produce an Euler Tour of vertex indices through Hierholzer's Algorithm, assuming all vertices have even degrees so the tour can start anywhere: (...
0
votes
0answers
18 views

Any algorithm that can ensure category diversity in K-size slide window reranking?

I’m trying to optimise the diversity problem in the search engine result pages. Imagine that for a search query, there’s N search results arranged in descending order of relevance. Each result ...
2
votes
1answer
120 views

Huge fibonacci modulo m C++

I'm trying to calculate Fn mod m, where Fn is the nth Fibonacci number. n may be really huge, so its really not efficient to calculate Fn in a straightforward way (matrix exponentiation would work, ...
1
vote
1answer
25 views

Shortest road between areas

I'm working on a game. I have to get the shortest road between areas and points. My problem is that there are some points that moves the player instantly to another area. I tried Dijkstra algorithm, ...
0
votes
0answers
14 views

Asymptotic notation - Algorithm to determine complexity class

I´m working on my bachelor thesis about Asymptotic notation. I have inputs for two functions and I need to find point "n0" like on this picture (point n) to determine complexity class and draw graph. ...
1
vote
1answer
58 views

Get nearest paper size from the list of available paper size

We have a pre-defined list of paper sizes, for e.g. PageSize = PageSize.A3, Height = 297, Width = 420 PageSize = PageSize.A4, Height = 210, Width = 297 PageSize = PageSize.A5, Height = 148, Width =...
-6
votes
0answers
74 views

returning 28 not 27?? why is mathematics wrong in this? C [on hold]

Why is this code returning 28 and not 27 when logic suggests 27 should return? I am using Luhn’s algorithm to attempt to 378282246310005 Okay, let’s multiply each of the indicated digits by 2: v ...
0
votes
1answer
39 views

Knight's Tour algorithm - TypeError: Cannot set property 'undefined' of undefined

I'm trying to implement Knight's Tour algorithm from the book "Algorithms and Data Structures" by N. Wirth. The original version is written in Oberon: https://drive.google.com/file/d/...
1
vote
1answer
56 views

Efficient methods of searching vectors for specific int's that meet a condition?

I'm trying to write an efficient operation to search through a vector, specifically identify the existence of three int's (A1, A2, A3) where A1 > A2 && A2 < A3. So given A {5,3,1,2,3}, the ...
0
votes
0answers
18 views

Coursera Assignment - better timing performance for detection of collinear points with mergesort

There is coursera assignment that tests the knowledge of mergesort(kind of) through practical application of finding collinear lines in 2D space. My solution passes correctness and memory tests, but ...
0
votes
0answers
33 views

How to best store a one key and billion values kind of data?

I have a requirement where I want to store the key-value kind of data but one key could have billion of values. There are mostly the read requests by key but there could be add/delete requests for ...
2
votes
2answers
30 views

Algorithm to remove minimal subset to make sequence order [duplicate]

I have a situation where I want to detect "outliers" in a supposedly sorted sequence. Elements that breaks the order are considered suspicious. For example the sequence 1, 2, 3, 4, 7, 5, 6, 8, 9 is ...
0
votes
0answers
14 views

Algorithms for relevance and ontology tree?

I have meta Data that are eddied made in my research paper i have references given at end I want to get ontology tree that is relevancy of given page with search keywords Calculate relevancy , given ...
2
votes
1answer
35 views

I'm trying to implement a merkle tree consistency proof, but I'm stuck at understanding the algorithm

I'm trying to implement a merkle tree consistency algorithm with this paper: https://books.google.de/books?id=CokSDQAAQBAJ&lpg=PA147&dq=merkle%20consistency%20proof&hl=de&pg=PA148#v=...
-3
votes
0answers
42 views

Round Robin Algorithm implementation check [on hold]

Hi Guys i tried to implement round robin algorithm in java. i need to know is there any other possibilities are there like for example do we consider processes priorities in it or the priorities ...
0
votes
3answers
62 views

I am converting numbers into words as well as showing them on screen also trying to show a word in javascript and html

I am trying to convert a number into word also showing them while i input the number , the same thing with a word where i input a word and it show while i type on screen, but having some trouble as ...
1
vote
1answer
31 views

3D Collision resolution, moving AABB + polyhedron

I have been writing a game engine in my free time, but I've been stuck for a couple weeks trying to get collisions working. Currently I am representing entities' colliders with AABBs, and the ...
0
votes
1answer
29 views

Quick ways to fill the missing values of a pandas dataframe with complicated rules

In the m*(n+1) pandas dataframe data_df, there is a timestamp column whose values are possibly repeated integers in range(0,p) (which denote time; there are p unique values in total) and no missing ...
0
votes
3answers
35 views

using filter and generator to generator endless prime number in python

Below is a python program I found to find prime numbers using Sieve of Eratosthenes. It uses filter and generator. I'm not able to understand it. def _odd_iter(): n = 1 while True: n =...
1
vote
2answers
59 views

Find sequential smallest sums of the multiples of three different numbers, javascript

On this post I found an algorithm to determine the luminance of an RGB color: Luminance (standard for certain colour spaces): (0.2126*R + 0.7152*G + 0.0722*B) I want to use this equation, starting ...
-2
votes
1answer
27 views

Method that checks if one word is a rotation of another

Working on the Cracking The Coding Interview problem that asks for a method that checks if one string is a rotation of another. The one caveat to the problem is that it must be solved with a single ...
0
votes
0answers
27 views

character rearrange algorithm implementation correctness

I'm working on the problem below and have posted my code of two different implementation alternatives. My question is, I have two versions of implementation, first version is (1) process most high ...
0
votes
1answer
17 views

Bitmasking--when to use hex vs binary

I'm working on a problem out of Cracking The Coding Interview which requires that I swap odd and even bits in an integer with as few instructions as possible (e.g bit 0 and 1 are swapped, bits 2 and 3 ...
-1
votes
1answer
32 views

How do I generate a list of permutations based on given characters and a length?

For example, I have a list of characters that I want to generate permutations of e.g. ['*', '+'] and a length that I want the permutations to be generated off e.g. 2. In other words, I want to find ...
0
votes
0answers
33 views

Complete algorithm for most general consisten specialisations of a concept

I'm studying for my course called "Introduction in Data Mining" and I'm following Peter Flach book "Machine Learning". I want to implement in Python the algorithm to find most general consistent ...
0
votes
1answer
32 views

Edge Detection Algorithm with Processing (Java)

i want to code an algorithm, that can do an edge detection for an image. I already have a part of the code, which detects all edges in horizontal way. Example picture: But i need an edge detection in ...
-5
votes
1answer
40 views

Tricky task about geometric progression

Given two numbers l and r. Need to find length of the longest geometric progression which consists of some numbers between l and r — int-numbers in interval [l,r]. Note that the ratio of geometric ...
1
vote
0answers
43 views

Huffman Encoding priority queue

I'm working on an assignment where I should write an encoding and decoding application for the Huffman algorithm, based on a priority queue. We have to read a file, count the frequencies of the ...
1
vote
1answer
63 views

Mergesort implementation is slow

Iam doing a report about different sorting algorithms in C++. What baffles me is that my mergesort seems to be slower than heapsort in both of the languages. What I've seen is that heapsort is ...
0
votes
0answers
103 views

Make palindrome substring finding algorithm O(n)

I recently did an online challenge and was asked to find the number of all consecutive chars, where it is symmetrical. e.g. 02002 would give the following 3 x 0, 2 x 2 (single digits are symmetrical)...