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
69 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
0answers
50 views

Type inference + overloading [migrated]

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 ...
21
votes
7answers
3k views

Should I keep investing into data structures and algorithms?

These days, I'm investing heavily in data structures and algorithms and trying to solve some programming puzzles. I'm trying to code and solve with Java and Clojure. Am I wasting my time? should I ...
10
votes
3answers
889 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) ...
3
votes
1answer
50 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 ...
5
votes
4answers
178 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 ...
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 ...
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 ...
0
votes
1answer
54 views

Even distribution through a chain of resources

I'm working on an algorithm which routes tasks through a chain of distributed resources based on a hash (or random number). For example, say you have 10 gateways into a service which distribute tasks ...
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 ...
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 ...
-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 ...
0
votes
1answer
139 views

Find possible variations of one item out of multiple baskets.

I have three baskets of balls and each of them has 10 balls which have the following numbers: Basket 1: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 Basket 2: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ...
3
votes
1answer
322 views

NLP - Queries using semantic wildcards in full text searching, maybe with Lucene?

Let's say I have a big corpus (for example in english or an arbitrary language), and I want to perform some semantic search on it. For example I have the query: "Be careful: [art] armada of [sg] is ...
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 ...
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 ...
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
1answer
210 views

What data structure is suitable for implementing dynamic huffman encoding and decoding on a piece of text?

Some pseudo code or resources will be appreciated.I was thinking if implementing it in form of a BST stored in an array. However,not all operations can be performed easily using this approach. I am ...
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, ...
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. ...
0
votes
2answers
251 views

What graph traversal algorithm should I use?

I would like to write an algorithm which can traverse a graph and hopefully later I can implement it to use for an indoor navigation system. The graph would come from floor plans of a building and ...
3
votes
2answers
328 views

Breadth-first graph search problem

I thought I was doing breadth-first graph search correctly, but my instructor's grading script is telling me that my answer is incorrect. From the instructions: Consider a breadth-first graph ...
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
1answer
94 views

Memoization Memory

Memoization is definitely a powerful technique. But Dynamic Programming is slightly better IMO, since it does not involve the memory strain (in a recursive program, the parameters occupy memory and ...
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
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 ...
31
votes
13answers
3k views

Unit-testing of inherently random/non-deterministic algorithms

My current project, succinctly, involves the creation of "constrainably-random events". I'm basically generating a schedule of inspections. Some of them are based on strict schedule constraints; you ...
0
votes
2answers
149 views

Application qos involving priority and bandwidth

Our manager wants us to do applicaiton qos which is quite different from the well-known system qos. We have many services of three types, they have priorites, the manager wants to suspend low priority ...
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
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 ...
0
votes
1answer
105 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 ...
1
vote
1answer
17 views

Given n distinct keys, how many different 2-3/Red-black trees can be constructed?

Memory refresher/My understanding: A 2-3 tree is a balanced search tree that allows two types of nodes. 2-node: Normal node with two children. LChild < Parent and RChild > Parent 3-node: ...
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 ...
26
votes
4answers
2k views

Can you use Pi as a crude random number generator?

I recently saw this question over at math.SE. It got me thinking. Could Pi be used as a crude random number generator? I mean the results are well known(how long has pi been computed to now?) but, Pi ...
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, ...
7
votes
2answers
249 views

What is an efficient algorithm for randomly assigning a pool of objects to a parent using specific rules

I need some expert answers to help me determine the most efficient algorithm in this scenario. Consider the following data structures: type B { A parent; } type A { set<B> children; ...
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
2answers
128 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
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 ...
1
vote
2answers
401 views

Radix exchange sort implementation?

I need a little help understanding the implementation of radix exchange sort algorithm. Radix exchange (I don't know if it's the exact name in english based literature) is a lot similar to quicksort, ...
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 ...