In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning.

learn more… | top users | synonyms (1)

0
votes
1answer
60 views

Estimed number of tries

Problem: The Oscar Committee wants to decide which person should get the best actor award among the given N actors.For that they decided to use a random function random_bit() which returns either 0 ...
1
vote
1answer
46 views

Type inference + overloading

I'm looking for a type inference algorithm for a language I'm developing, but I couldn't find one that suits my needs because they usually are either: à la Haskell, with polymorphism but no ad-hoc ...
10
votes
3answers
885 views

Would using a hash table in garbage collection solve the stop the world problem of mark and sweep?

In mark-sweep-compact garbage collection algorithm you have to stop-the-world when relocating objects because reference graph becomes inconsistent and you have to replace values of all references ...
-3
votes
1answer
57 views

Shuffle all songs iOS [on hold]

How does iOS shuffle all songs pick which track to play? So search I found a theory that says, it has two different sets one set consists of song ID's that have been played and another set(set2) ...
4
votes
4answers
176 views

The optimal recipe problem

Suppose I have a list of Ingredients In My Fridge which are going off soon, and a list of Recipes which use up various Ingredients. (Some of which I don't currently have.) Is there an algorithm which ...
1
vote
0answers
142 views

Does a 15-puzzle always have a solution [migrated]

For those that are not familiar with (this type of) sliding puzzles, basically you have a number of tiles on a board equal to (n * m) - 1 (possibly more holes if you want). The goal is to re-arrange ...
-2
votes
0answers
21 views

Extracting visual data from a Program for external use [closed]

I am looking at basically capturing VU Meter data from an audio recording program, preferably the highest resolution possible, and inputting that data into a circuit to power LED's, respectively. I ...
-1
votes
0answers
42 views

Algorithm to generate all reduced latin squares of order 6 without recursion [closed]

I have looked this up over the internet and i could find methods for generating a balanced latin square or find a randomized instance of a latin square given an order (Sudoku board generator) I need ...
3
votes
1answer
36 views

Difference in orientation of Sobel mask gives different edge detector result

I am implementing a Canny Edge detector for a class which I have based off the code found here. For the first derivative mask that I will convolve with the image, I am using the Sobel mask, although ...
-3
votes
0answers
19 views

how should I use precision in this mathematica code? [closed]

I am writing a mathematica code where I have 19 parameters (m,EX1,DX1 and so on). To begin with a specific guess value is assigned to each parameter that I am updating within the loop. Now I am ...
3
votes
2answers
139 views

Search for the (slowly moving) number with penalty for too high test value

You task is to design a search algorithm that will find my secret number, which is between 0 and 2^64. If your test value is too low you can test again in 1 second. If your test value is too high you ...
0
votes
1answer
31 views

How can I approach creating an efficient algorithm for maximizing value with these specific constraints?

I'm having trouble coming up with an approach that isn't n^2 for this problem. Here's a contrived, simplified version I've come up with: Let's say you're a company that needs 4 employees to launch in ...
-1
votes
0answers
11 views

Finding in std::list [migrated]

Tell me please how to do that the best using STL. I have class that has a member std::list. It's private member. I have only const_iterator to begin and end. I'd like to check if list has some ...
2
votes
1answer
163 views

Is there a purely SQL alternate to looping?

Historically, I probably would have written a script (php or something) to loop through all spreadsheet rows and perform some calculations. I'm looking for a pure SQL solution on the presumption ...
0
votes
0answers
24 views

Algorithm for inserting into sorted subset

A is a sorted list. B is a sorted list, and a subset of A. If an element is inserted into A at index i what's the most efficient way to determine the correct index i' for it's position in B? Given ...
0
votes
1answer
37 views

Parallel radix sort algorithm

I am trying to implement radix sort. While I understand the radix sort for serial implementation, I am confused about parallel implementation. I am trying to implement the algorithm given in ...
2
votes
0answers
81 views

Why isn't there parallel reduction in the Standard Template Library?

Alexander Stepanov stated in talks and interviews that his realization that eventually lead him to generic programming and the Standard Template Library, was from the case of the parallel reduction ...
0
votes
0answers
42 views

Algorithm to Select Sequential Subarrays from an Array

I solved my problem by using simple nested loops and comparisons but I'm wondering if there is a well known Selection Algorithm to solve my problem. Let's say I have an array such as [1, 10, 250, 9, ...
0
votes
0answers
65 views

Algorithm / working approach to get a random list of data

I am working on a android schedule app but that isn't matter , the problem is a algorithm / methodology so you are welcome to just write the pusedo code to answer. The data is like this Place ...
1
vote
2answers
116 views

Smallest and Largest contiguous repeating sub-sequence in a sequence

I am trying to solve a outdated quiz problem. I am tasked to find the smallest and largest contiguous sequence of repeating numbers in a larger sequence.e.g. ...
3
votes
1answer
49 views

Comparing absolute values when determining zero crossing in 2D image

I am trying to implement an algorithm for finding the zero crossing (check that the signs of all the entries around the entry of interest are not the same) in a two dimensional matrix, as part of ...
0
votes
0answers
29 views

Maximize the visibility of an ad to a maximum of people in an automatic advertising system

I have N different ads that I want to display at the same time to M people in an automatic advertising system. Some people will never see some ads because they only check some specific criteria on the ...
2
votes
3answers
110 views

How to implement a Weighted shuffle

I recently wrote some code that I thought very inefficient, but since it included only a few values, I accepted it. However, I'm still interested at a better algorithm for the following: A list of ...
0
votes
1answer
104 views

Euclidean Space Fully Connected Nondirectional Graph: Shortest Path to all nodes

So this may be a question that is born of my inability to properly express my intentions to Google. In a fully connected non-directional graph such that any three points can be properly represented ...
0
votes
0answers
3 views

Number Patterns using loops in Java [migrated]

I have been trying different variations of for loops and have no clue how to make these patterns: Pattern 1 54321 5432 543 54 5 Pattern 2 1 12 123 1234 12345 Pattern 3 12345 2345 ...
-1
votes
1answer
67 views

Optimal movie schedule

Let's say Mr. A goes to cinema and he gets a movie schedule. There are N movies on the program today (1 < N < 50) and for every movie the time of the start and the time of the end are given in ...
1
vote
2answers
120 views

Given two sorted array in ascending order with same length N, calculate the Kth min a[i]+b[j]. Time complexity O(N)

Given two sorted array in ascending order with same length N, calculate the Kth min a[i]+b[j]. Time complexity O(N). Another variant of the question goes like this: given a matrix with sorted rows, ...
0
votes
3answers
249 views

Print bottom view of a binary tree

For a binary tree we define horizontal distance as follows: Horizontal distance(hd) of root = 0 If you go left then hd = hd(of its parent)-1, and if you go right then hd = hd(of its ...
3
votes
2answers
197 views

How to find number of points with same minimal distances on matrix

I'm trying to find the number of points in a matrix with the same minimal distances. Start with a MxN matrix, where M and N < 50000. There is given a set of fixed points, with their respective ...
0
votes
2answers
127 views

Solution Checker Algorithm for a Game

For the moment I'm strictly speaking in Pseudocode. I'd only like to see if i'm on the right track. The game I'm talking about is similar to a application called FLOW. In this game, you're given a ...
0
votes
1answer
192 views

Beginning Data Mining

For simplicity, my database has entities and transactions. Each transaction has a DateCreated and a foreign key to the entity. I'd like to have the ability to find entities that have had a recurring ...
0
votes
1answer
60 views

How can a route finding program avoid obstacles/locations when calculating routes? [closed]

Do you delete nodes from the underlying graph representation? Or is there a more elegant way to do it?
0
votes
0answers
20 views

Calculating combinations from categories

I'm trying to calculate every possible selection from different categories. 1 choice must be made from every category and the categories are always in the same order. I save a string where each ...
-1
votes
1answer
153 views

How to create a some kind of value for sentences? [closed]

I want to identify most matching sentence using some pattern. That means by using java algorithm I want to create identical value for each sentences.Each sentence when entering to that algorithm can ...
0
votes
0answers
28 views

Readers Writers algorithm help - starvation and no starvation

I found this link, as an explanation of r/w problem - http://pages.cs.wisc.edu/~bart/537/lecturenotes/s7.html But, I'm having problems realizing is there any starvation present here and why? Also, if ...
-1
votes
1answer
63 views

Difficulty implementing algorithms from abstract understanding [closed]

I've got decent programming experience for an undergraduate. I just started the study of algorithms. I read the description and saw visual examples that make perfect sense in my head. But when it ...
-5
votes
2answers
100 views

Best and worst case for the quicksort algorithm with 7 elements

part of my final project for my computer science class is developing a computer program that implements quicksort, but as a sort of pre-requisite, our teacher has given us this problem. Find 7 ...
1
vote
0answers
89 views

How to extract the active code path from a complex algorithm

I have been puzzled lately by an intruiging idea. I wonder if there is a (known) method to extract the executed source code from a large complex algorithm. I will try to elaborate this question: ...
2
votes
2answers
86 views

Set distances algorithm question

I have multiple sets containing integers. An integer maybe present in one set or multiple sets. I would like to find/match the sets with the most common integers. Example s1 {1, 2, 3, 4} s2 {1, 3, 4, ...
1
vote
2answers
182 views

What is a O(n) algorithm to solve this puzzle?

We are going to hold a meeting where everybody will speak in clockwise direction around a table. There are n people with n spots. Each person has a position preference (e.g. some want to go first, ...
0
votes
1answer
38 views

How do I mutate a value in a genetic algorithm using Gaussian distribution?

I've been reading 'Introduction to Evolutionary Algorithms'. This method is stated, but not described, and I can't find anything more specific online. p44/45 of 2nd Ed for reference. "adding to the ...
6
votes
1answer
131 views

Heuristic Approach for Flexible DIFF Implementation

I have created a DIFF implementation to compare document revisions at work. It is based on An O(ND) Difference Algorithm and Its Variations. One thing that has become important is to take the list ...
0
votes
1answer
121 views

How to develop an algorithm for brute-forcing / backtracking?

As a beginner programmer, I don't know how to conceptually think about brute-forcing. My mind can't really fathom how to write code that will try every possibility. I have a problem that I want to ...
1
vote
1answer
115 views

LLVM case: is the success due to the algorithms? [closed]

I'm not sure if this is a subjective question, I hope not but I'm not proficient with LLVM so I'm just wondering: how come it's become so popular and so widespread used in the industry? Were the ...
1
vote
1answer
61 views

Efficient algorithm for joining sieves

I'm trying to find an efficient algorithm for the following algorithm. I have a sequence consisting of lists of indices denoting indices to be removed. The semantics are such that each sequence must ...
3
votes
4answers
169 views

Building complex algorithms with TDD

I'm trying to adopt TDD in my daily programming practice. I use it at work very effectively, but I'm having trouble with my personal projects where I'm using some complex algorithms. The particular ...
0
votes
2answers
214 views

Algorithm to order array

Take for example this input array: [2,7,1,4,9] For this input, I need to produce an array of total 23 elements which contains two elements of 2, seven elements of 7, one element of 1, four elements ...
3
votes
1answer
73 views

Which machine learning approach should I look into? [closed]

Consider an application in which users fill out a form of (six or so) inputs and are offered widgets from an inventory based on their inputs; from the widgets they are offered, they must select one ...
0
votes
0answers
28 views

Algorithm for HIghest Local Alignment Score with a specific character match between two subsequences

I'm writing a code that identifies the highest-scoring local alignment between a substring X' of X and a substring Y' of Y that has at least one column in which a C from X' is aligned to a W from Y'. ...
0
votes
3answers
115 views

Least Change Problem with Thousands of Denominations

In a hypothetical economy there are currency units that can represent thousands of different values. So, for example there might be coins worth 1c, 3c, 5c, 7c, 7.5c, 80c, 8001.5c etc. Given a list of ...