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)

0
votes
0answers
5 views

Checking for possible path algorithm(ruby)

Im currently taking a module on computer logic and algorithms. I'd like for some help in helping me solve the problem below (by editing my code) or pointing me in the right direction i.e A better ...
0
votes
0answers
8 views

2D Tile or Vector map to 3d earth like map

i search for an algorithm for generating a 2.5D image or 3d Image from 2d tiled or a vector image, actually i want to create a plugin for OpenCPN So that its maps when zoom in looks like 3D (like ...
-1
votes
1answer
31 views

How to find the nearest prime number in an array, to another number in that array?

I wanted to find out the nearest prime number (that is present in that array), to any another number in the array ? Example : list a -> [1,2,4,6,8,12,9,5,0,15,7] So the nearest prime number to 4 ...
0
votes
0answers
29 views

Faster edit distance algorithm

Problem: I know the trivial edit distance DP formulation and computation in O(mn) for 2 strings of size n and m respectively. But I recently came to know that if we only need to calculate the minimum ...
0
votes
2answers
14 views

Confused in Big Theta Notation - Asymptotic Notation

I am trying to understand the Big Theta notation and came across an example : I know we have to find two constants c1 and c2 for this notation such that c1*g(n)<= f(n) <= c2*g(n). My question ...
0
votes
2answers
20 views

Why is bidrectional search more efficient in BFS?

Imagine a line, with two nodes, A in -10, and B in 10, using uni directional search, we search from (-30, 10) and using bi directional search we search from (-20, 0)and (0, 10) and (10, 20). Either ...
0
votes
0answers
6 views

Radix 2 Modified Booth algorithm

What is Radix 2 Modified Booth algorithm ? Is there any difference between Radix 2 Booth and Radix 2 Modified Booth algorithm.
0
votes
1answer
29 views

Simplify a sum of log n/3i

I have the following equation: W(n) = w(n/3) + lg(n) W(1) = Theta(1) and I want to find its time complexity. It can not be solved by the master theorem(can anyone confirm) so I have do that I by ...
1
vote
0answers
48 views

Maximum element after M operations

Given are the 3 elements N1,N2,N3 Now we can perform operation on these elements. Operation is as follow : In a single operation,we will choose a particular element and decrease the value of ...
-4
votes
1answer
22 views

I don't know whats going on

I have no idea how to fix this, i originally wanted it to print "hello[0]", what im trying to do is create a bubble sort algorithm ( copy from textbook ) to see if it works, but its obviously a ...
0
votes
1answer
24 views

Segmentation of strings using dynamic programming

Suppose you have a function quality(x) that returns the quality of a sequence of letters x. Given a string such as "howareyoutoday," what is the most efficient way to determine that the segmentation ...
0
votes
0answers
18 views

Wrong hashing value for Sha-256 algorithm

I am currently working on a Sha-256 hashing algorithm implementation. I do know both the JCA and apache libraries pack this - I am merely doing this to learn. The specification I used was the FIPS ...
1
vote
1answer
30 views

Dijkstra's Dilema: How can I make my Algorithm abstract?

I was doing code forces and wanted to implement Dijkstra's Shortest Path Algorithm for a directed graph using Java with an Adjacency Matrix, but I'm having difficulty making it work for other sizes ...
1
vote
1answer
24 views

Red Black Tree implementation in Python

My problem stems from trying to insert the last node (red one) in these two scenarios: This is the traceback message I get: Traceback (most recent call last): File "<stdin>", line 1, in ...
-6
votes
0answers
19 views

compute the number of shortest paths from v to w [on hold]

Given an undirected graph G=(V,E), and two different nodes v and w, write an algorithm to compute the number of shortest paths from v to w. Implement the algorithm in a class called Network with a ...
-2
votes
1answer
40 views

test the speed of quicksort

I read the book of Algorithm 4th edition princeton and watched the online course video. I have found two interesting things. It was said in the video, if we use a cutoff like this in quicksort, we ...
0
votes
2answers
80 views

smallest element in a array of strings c++

I am trying to find the smallest element in a array of strings but I can't figure out how to do this. I came up with this code idea which works perfectly for integers but does not work for strings. ...
0
votes
2answers
51 views

Missing arguments that shouldn't be missing(Python)?

I'm currently writing a simple "combat algorithm"(if that's the term for it) that will eventually be built up to be more and more complex, but right now the most it needs to calculate is damage done, ...
0
votes
0answers
38 views

Input array has random 0s at random positions: Java (mergeSort)

My input array for my merge sort algorithm has random 0s at random positions: import java.util.*; import java.lang.*; class MRS { public static int [] A = new int [8]; public static int [] ...
-2
votes
0answers
29 views

Previous lexicographic permutation

I have given a permutation of numbers 1 to n.I have to find its preceding lexicographical permutation if it is not a completely sorted(non decreasing) permutation. Can anyone please help me...
-5
votes
0answers
48 views

Hackerrank challenge named twotwo. Algorithm and solution explanation needed

The question on hackerrank here asks to use the Aho Corasick algorithm, which I spent days reading and understood nothing :/. Anyhow there is a solution given by tester(tmt514) which solves the ...
-4
votes
0answers
30 views

Hashing table in C [on hold]

In java Hash Table can be simple formed by: HashMap<String, String> table = new HashMap<String, String>(); How to form the HashTABLE in C.PLease Explain why time complexity for search ...
-6
votes
0answers
59 views

Minimise the maximum element [on hold]

Given are the 3 arrays with N1,N2,N3 number of elements. Array1 is represented as A given by A[1], ..., A[N1]. Array2 is represented as B given by B[1], ..., B[N2]. Array3 is represented as C given ...
1
vote
2answers
21 views

Algorithm to validate free polygon vertices for a non-intersecting shape

I have been tasked with allowing a user to enter any number of arbitrary points on a canvas and link them together in the order that they were specified to draw a polygon. However, each time the user ...
0
votes
3answers
68 views

Is Data-Structure and Algorithm same for all programming languages?

If a person learns data-structure and algorithm in one programming language does it needs to learn other language's data-structure and algorithm ? As i am about to start a book Data-structure and ...
-3
votes
0answers
32 views

program to make end points of segment into vertices and edges [on hold]

I am writing a program to find shortest path between two points. there are set of line segments as obstacles between them. I am using Dijkstras algo to calculate. But for calculating the shortest ...
1
vote
1answer
44 views

Doing advanced logic in SQL (T-SQL) - Matching algorithm

Ok, so this particular use case is giving me quite a bit of headache. This is a edit of another post, where i forgot to add an important aspect to the usecase. What is need to do is match a ...
0
votes
0answers
47 views

What would be an easy way to visualize pathfinding algorithms in C++? [on hold]

The algorithm seem to be working and now I need a quick and easy way to visualize them in C++. I have no prior experience in graphics programming. Can someone recommend any libraries which are easy to ...
1
vote
1answer
72 views

A fast way to find one point per region

I am writing some code that chooses n random hyperplanes in 5 dimensions that go through the origin. It then samples no_points points uniformly at random on the unit sphere and counts how many of the ...
0
votes
2answers
44 views

Create winnable “random” solitaire shuffles

I've created a solitaire game for Mac, but people keep complaining that there's not enough "winning" shuffles. People have a win-rate of about 5%-10%, where their usual win-rate is around 50%. Right ...
0
votes
0answers
42 views

How to improve the efficiency in a simulated Zuma Game?

I am writing an easy program which acts like a Zuma Game. Different upper letters denote marbles with different colors. And the first input line will be the current marble sequence, second input line ...
0
votes
0answers
17 views

Getting a list of popular people right now/today

I'm trying to get a list of most popular or most searched poeple for today or right now. I'll use the list to develop an app. Google trends only shows for the last year. Daily trend is mixed. I need ...
1
vote
2answers
32 views

Generate subsets of a given binary string, how does this code work?

I encounter this code snippet while looking for answers for subset generation. start N; //an integer X = N while true print X if( X == 0 ) break; X = (X-1) & N; end while ...
0
votes
5answers
58 views

Recursion function returns wrong value

I have wrote the following code for generating sum of number e-g if I enter 10 it will generate it's sum like 10+9+8+7+6+5+4+3+2+1+0 output : 55 which works fine. public int GenerateSum(int num) ...
0
votes
2answers
53 views

Boiling Vegetables minimum number of cuts

I am trying to solve this problem https://warmup.kattis.com/problems/vegetables What i am wondering is how should one divide a vegetable into two pieces. If I make wleft=wright=1/2 * w then it is not ...
0
votes
0answers
45 views

Unable to figure out how to fix NullPointerException in java [duplicate]

I'm trying to implement AVL Tree in java but got stuck for a day now because of nullpointer exception .I have went through different articles to remove it but no success. can anyone please help me ...
0
votes
0answers
31 views

Find unknown checksum algorithm from captured data

I want to communicate with some device that uses proprietary protocol. First communication is initiated with two bytes, which are used somehow later to calculate checksum of each message. For ...
0
votes
3answers
50 views

Taking input from user using do while loop in c

I am creating a program for generating next prime number, for which I need to take user input.I am using do-while loop but it doesn't stop to take input for second time. Please guide me where I am ...
1
vote
2answers
31 views

Checking if given preorder traversal is valid BST

I was writing code to check from preorder traversal if it is a valid BST. e.g preorder traversal 1,2,4,3,5 is valid BST while 1,3,4,2 is not I built whole tree from that preorder sequence and then ...
1
vote
0answers
32 views

Parsing an ad-hoc tree

I have a flat file that appears as follows: Soccer +Team:US ++Shirt:Red & White Stripes ++Shorts:Blue ++Players:17 +++Active:11 ++++Forward:2 ++++Midfield:4 ++++Defense:4 ++++Goalkeeper:1 ...
0
votes
0answers
19 views

Chinese character recognition [on hold]

For research purpose, I want to develop a web app using node JS that recognize mandarin character and it can also recognize what I write in a provided canvas (html 5). So what should I use for the ...
0
votes
1answer
28 views

different binomial coefficient algorithm's efficiency compare

I've compared two algorithms to calculate binomial coefficient C(n, k) as bellow, #1 uses formula to calculate, #2 uses dynamic programming. #include <stdio.h> #include <sys/time.h> ...
-1
votes
0answers
28 views

Permutations using a 2D array

I need to write a short program that is able to output the permutations of the input which can be one of the following integers: 1, 2, 3, 4, 5 or 6. I need to store the permutations of in a 2D array ...
0
votes
0answers
23 views

Finding Shape Outlines Within a Bitmap? [on hold]

So, I've been working out this problem for a few hours now, hopefully there's nothing obvious I am missing. I have a bitmap file and I would like to create a List such that the list just contains ...
0
votes
0answers
40 views

Aren't there any faster algorithms to solve cubic equations?

I'm looking for a fast algorithm which solves cubic equation. Complex roots are not needed. Currently, I'm using the algorithm written in the following URL. Aren't there any faster ones? ...
0
votes
1answer
23 views

Finding the running time when it comes to constants?

I am attempting to answer some questions that I've come across. I have been watching some videos regarding running time of algorithms. From what I understood, you have to count each operation in an ...
1
vote
1answer
26 views

Find the smallest subset of overlapping intervals

Consider a question to find a minimum dominating set of an interval graph. In the context of interval scheduling, it is converted to the question below: There are multiple intervals which may or may ...
0
votes
1answer
47 views

How to solve this programming contest exercise

I stumbled upon this algorithm question, I couldn't get any better approach than brute force, can someone guide me please? Given a M * N grid of characters (A,B). You are allowed to flip any ...
-1
votes
0answers
46 views

a hash algorithm that return unique value and 16 or less Char string [on hold]

Hello guys: I am trying to use some kind of algorithm to give me a unique value for a string input. For a different string i want different hashed value <= 16 characters long. I have checked some ...
0
votes
2answers
17 views

How to best get the data out of a lookup table

I have a few product lines with products that have various features. I have a list of drawings made for each product, and below is a sample of what the product lines, products, and features are ...