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
1answer
21 views

What is the max buffer value such that an array of ints will be sorted in increasing order?

Problem: Given an array of integers, find the minimum buffer value such that the array can be sorted in strictly increasing order. Each element in the array can add or subtract up to the buffer value. ...
-4
votes
0answers
19 views

Converting an algorithm into code (python 3.4.1) [on hold]

I've been given an algorithm which i need to convert into code but I cant for the life of me work it out. The algorithm is: Algorithm to display the frequency to the screen: index = 0 WHILE index ...
1
vote
1answer
43 views

seek the fastest sorting algorithm for some arrays

I have some short arrays that have been sorted. then I want to merge them into one large arrays and required to keep order. so how to implement that in fastest time and simplest complexity. for ...
-3
votes
1answer
20 views

Generate a unique numeric value for a string

I have a number of unique strings (dictionary words) and I would like to generate a unique numeric value for each string. The requirement is that the same string should always map to the same numeric ...
0
votes
0answers
15 views

what are the steps to be consider when you are designing a search application?

Let's say these are the requirements : 1. It connect to database to search 2. Number of tuple in DB is too huge 3. search Hits thousands of query in seconds 4. It should be ...
0
votes
1answer
11 views

String matching alternate approach

Trying to write my own fast pattern matching algo. Dont want to use language specific solution. I am focussing on writing the algo. This is because I was reading about different techniques to do ...
0
votes
0answers
11 views

SFML | How to rotate a sprite to a point?

I'm trying to to rotate a sprite, let's say it's a gun, to a point, by taking the smallest route possible on a 360° (right or left depending on what side the point is closer to) and I'm having a few ...
0
votes
0answers
3 views

Are there any heuristic client fetching strategies/algorithms/theory in CRM WebApplications (call center)

I am creating a ASP .NET MVC CRM for my company to be(not yet exists). We are going to call some people from our database(no phone spam or similar). We got a fullfiled database of people, about 2000 ...
-1
votes
0answers
16 views

given a set S of n integers and another integer x, determines whether or not there exist k (n>k>2) elements in S whose sum is exactly x

given a set S of n integers and another integer x, determines whether or not there exist k (n>k>2) elements in S whose sum is exactly x. If possible the Running time
0
votes
1answer
74 views

Minimum number of distinct characters to result in a given suffix array

Given a suffix array, a TopCoder task from SRM 630 asks to find the minium number of distinct characters in the string that could form a string with the given suffix array. The full problem statement ...
0
votes
1answer
15 views

Guidance to understand Base64 encoding algorithm

I found this algorithm on the net but I'm having a bit of trouble understanding exactly how it works. It encodes an Uint8Array to Base64. I would like to understand especially the sections under the ...
2
votes
0answers
22 views

Effective multi-search algorithms

Reason for posting question: My programming experience is somewhere between amateur and moderate (but I'm pretty rusty at this point). I'll probably be working with C++, but I would be willing to ...
2
votes
4answers
26 views

Organize objects by date range in Java

I have a List of Stat objects and each Stat has a Date field. This list may be very large. What I would like to do is organize these objects into date ranges (weeks to be specific) efficiently. So, if ...
1
vote
0answers
15 views

Need a similarity measure for these vectors

I have a Python function that takes in a block of text and returns a special 2D vector/dictionary representation of it, depending on a chosen length n. An example output might look like this: 1: [6, ...
0
votes
1answer
32 views

Subset product & quantum computers, is an instance solvable

Suppose you have a quantum computer that can run Shor's algorithm for factorization of integers. Is it then possible to produce an oracle that determines if no solution exists for an instance of the ...
1
vote
1answer
14 views

ML approach for clustering product descriptions

I need to cluster different descriptions of parts from catalog data from different vendors. I am trying to find an "approach" that can detect clusters of similar descriptions for purpose of grouping ...
0
votes
0answers
10 views

Parallel AdaBoost: multiple classifiers with same feature?

I am trying to implement Parallel AdaBoost. It was first introduced in the paper "Logistic Regression, AdaBoost and Bregman Distances" by Collins, Schapire and Singer. It was also implemented in a ...
1
vote
2answers
28 views

Min-Heap to Max-Heap, Comparison

I want to Find Maximum number of comparison when convert min-heap to max-heap with n node. i think convert min-heap to max-heap with O(n). it means there is no way and re-create the heap.
0
votes
1answer
21 views

Neo4J - Traveling Salesman

I'm trying to solve an augmented TSP problem using a graph database, but I'm struggling. I'm great with SQL, but am a total noob on cypher. I've created a simple graph with cities (nodes) and ...
2
votes
1answer
31 views

Time Complexity of one basic example

I ran into an example and want to calculate the order (time complexity) of this code. May someone help me understand how to calculate the order of this code: f(n) { i=0; while (n>0) { ...
1
vote
1answer
51 views

What's time complexity of this algorithm for Wildcard Matching?

Wildcard Matching Implement wildcard pattern matching with support for '?' and '*'. '?' Matches any single character. '*' Matches any sequence of characters (including the empty ...
0
votes
3answers
46 views

Count number of operations in algorithm

I have to count exact number of operations that algorithm performs: count = 0 for( i=0 ; i<=10 ; i++ ) for( i=0 ; i<=10 ; i++ ) count += (i + 10) / 2 I understand that its ...
0
votes
4answers
79 views

Does “Find all triplets whose sum is less than some number” have any solution better than O(n3) runtime?

I got asked this on an interview. "Given an array of ints, find all triplets whose sum is less than some number" After some scrambling I told the interviewer that the best solution would still lead ...
0
votes
3answers
38 views

Find all Factors for Phony Numbers

I am trying to find the quickest full factor algorithm. I use put all the factors into an arraylist for addition and compare the sum against the original number to find out if they are the same. ...
0
votes
2answers
42 views

Two players game - how to match them using database?

I'm developing a simple game program. This game is web based and two players play each other. Now I need to match the player randomly. The method I used was as below. Player comes in -> put the user ...
0
votes
3answers
49 views

Change Hash Array keys to strings

I have this Hash: {["word"]=>1, ["cat"]=>2, ["tree"]=>1, ["dog"]=>1} But I want to have this Hash: {"word"=>1, "cat"=>2, "tree"=>1, "dog"=>1} I have made several attempts ...
1
vote
4answers
33 views

Iterate through multiple arrays, in a different way

Although I'm trying to solve this problem in Ruby, I'm welcome to suggestions in other languages that I can take back to Ruby. I have any array: color = ["red", "green", "blue"] size = ["small", ...
-3
votes
0answers
22 views

spoj dp lsort approach

http://www.spoj.com/problems/LSORT/ It is a problem on spoj It states that An N-element permutation is an N-element sequence of distinct numbers from the set {1, 2, ...,n}. For example the sequence ...
0
votes
0answers
23 views

Algorithm for calculation valid apm

Surprisingly I can't found algorithm for calculating apm(Action Per Minute). What is best pattern for correct calculation valid apm? I tried little bit create some, but I not sure it is good ...
0
votes
0answers
17 views

Building infrastructure graph for dependency analysis [on hold]

I'm building a dependency analysis tool for infrastructure, more so like facebook for infrastructure. I'm using Redis for representing adjacency list. Below is my use-case: Lets say the system ...
0
votes
1answer
29 views

confusion about rod cutting algorithm - dynamic programming

I recently saw a rod cutting problem, where B(i) = optimal price for cutting a rod of length i units and p(i) = price of a rod of length i units. The algorithm given is something like this: B(i) = ...
0
votes
2answers
31 views

Caculating coordinates of specific point on the line [duplicate]

So, I hope this still classifies as coding, not math... Oh well, aren't they same anyway ;) So, my problem is this: I would want to calculate coordinates of a point on line. For example, if I had ...
-1
votes
3answers
44 views

How to get maximum sum of numbers drawn from multiple arrays - permutation don't work (16!) [on hold]

Yesterday I asked about How to find the maximum possible sum of numbers in arrays drawn from a unique array index and I was advise to use permutation - it worked well, but I wasn't aware that my ...
3
votes
1answer
38 views

Does the dataset size influence a machine learning algorithm?

So, imagine having access to sufficient data (millions of datapoints for training and testing) of sufficient quality. Please ignore concept drift for now and assume the data static and does not change ...
0
votes
0answers
18 views

Finding polygons created by set of infitnit lines [on hold]

I am looking for an alorithm that finds all the (closed) polygons that are created by a set of inifinit lines. I am sure that someone already solved that problem, but my search efforts were without ...
0
votes
1answer
15 views

MEX rule and Nimbers : Combinatorial Game Theory

I've been reading this small tutorial on Nimbers and game theory. Could someone explain why the mex rule governs the nimber of a game position? See: http://en.wikipedia.org/wiki/Mex_(mathematics) ...
0
votes
0answers
24 views

TSP through user-defined points

I have some set of points, and there is subset of points, marked as "static". So I need to solve TSP, which will create best path including marked points in static positions. How can I to solve it? ...
0
votes
2answers
22 views

Ambiguity about the Big-oh notation

I am currently trying to learn time complexity of algorithms, big-o notation and so on. However, some point confuses me a lot. I know that most of the time, the input size of an array or whatever we ...
-1
votes
1answer
32 views

Graph algorithm for min path [on hold]

I came across a question where in a directed graph with two matrix indicating cost to travel from one vertex to another and other one indicating time to travel from one vertex to another,I had to find ...
0
votes
3answers
71 views

find the number of divisors for a number in range

I have question regarding the CountDiv problems my code is wrong apparently, The problem given is: "Write a function: class Solution { public int solution(int A, int B, int K); } that, given three ...
0
votes
1answer
15 views

Getting 'next' and 'previous' when sorted by field that is not unique

I'm making a gallery of images. User can sort this gallery by rating: SELECT * FROM images WHERE album_id=8 ORDER BY rating DESC, id DESC LIMIT 0, 10 This will result in list of images, that I ...
1
vote
0answers
55 views

Sorting string so that there aren't two same characters on adjacent places [duplicate]

So I need to make a java program that reorganizes string so that there are no two same letters on adjacent places. If possible it would also put the string into alphabetical order. For example ...
9
votes
6answers
292 views

Lexicographic minimum permutation such that all adjacent letters are distinct

It's a bonus school task for which we didn't receive any teaching yet and I'm not looking for a complete code, but some tips to get going would be pretty cool. Going to post what I've done so far in ...
0
votes
0answers
12 views

3DES encrypting and decrypting in C#

I am working on a project to optimize 3DES and I have already managed to implement it using the security.cryptography library. However, I want to go low level so I need to implement Triple-DES without ...
2
votes
0answers
49 views

Calculating the fastest routes and some points on the same time

I have two drivers and each driver has a set of about 15 locations where they need to drive to on a single day. Calculating the shortest route for both drivers is not the problem (using a matrix ...
0
votes
0answers
42 views

Concatenate and retrieve strings

I have a set of strings S = {S1, S2, ...} Each string has these properties: arbitrary length is a sequence of symbols in base4 (0, 1, 2, 3) there are never four different symbols expressed in each ...
1
vote
3answers
63 views

Efficient solution for my task needed

I had to solve a problem in java. My solution was not very efficient (score 4/10)/ Problem: There are three machines: RR*,MM,PP RR(0)=3,MM(0)=1 and PP(0)=0 On day i(i>0) No of RR production ...
-1
votes
1answer
58 views

A strange recursive code [on hold]

Could anyone describe me, or give me an example of, how the following code works? I am confused with the recursion! It is a typical example of recursion, but I could not understand. The algorithm is ...
1
vote
2answers
32 views

Sequence of Some Algorithms on Sorting

i see in some midterm or final exam on MIT that the following question repeat and repeat in same manner. we show an array in the some step of one sorting algorithm. 5,3,1,9,8,2,4,7 ...
-3
votes
0answers
25 views

give your algorithm to the computer system [on hold]

give your algorithm to the computer system What will I have for dinner?  biryani (large enough to feed 2 persons)  mango juice  aloo fry