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)

4
votes
3answers
2k views

Parsing scripts that use curly braces

To get an idea of what I'm doing, I am writing a python parser that will parse directx .x text files. The problem I have deals with how the files are formatted. Although I'm writing it in python, I'm ...
17
votes
4answers
6k views

In pseudo code what does := mean?

The section entitled Algorithmic Implementation has the following code: // Return RC low-pass filter output samples, given input samples, // time interval dt, and time constant RC function ...
4
votes
1answer
683 views

Hashing Algorithm: Deleting an element in linear probing

While using Linear probing method to implement hashing, when we delete and element, the position of the deleted element is declared as a tombstone/ mark it as deleted. Why can't we just shift all the ...
1
vote
1answer
908 views

Matrix Pattern Recognition Algorithm for a 2D space

I have a picture that I elaborate with my program to obtain a list of coordinates. There is a matrix represented in the image. In an ideal test I would get only the sixteen central points of each ...
5
votes
3answers
351 views

Algorithm to pick user

I need an algorithm for picking a user. Users are identified by letter {A, B, C, ...} and are ranked by number {1, 2, 3, ...}. Rank is the degree of likelihood to be picked, so a rank 2 user is ...
2
votes
1answer
100 views

Sorting with continous input

I'm designing (not writing, yet) a task scheduler system for a complex video game. The rest of the program passes it objects containing a function and some metadata including an estimation of how much ...
3
votes
4answers
867 views

How to determine most challenging test-cases to test any algorithm?

While solving any problem, we write algorithms. Some efficient, some not, some work, some fail. But sometimes we end up writing something which is mostly a success when we do a dry test run, perhaps, ...
-5
votes
2answers
115 views

Calculate transfer time while accounting for loss of conductivity and speed over circuits [closed]

So based on my limited understand of how computers work I derived the following question. As you transfer things over circuits the circuits heat up. As they heat up they lose conductivity and ...
0
votes
2answers
222 views

How can I compute maximal area including only given integer pairs of (x,y) coordinates?

The values ​​of a function of two variables z = f (x, y), where x, y, z take integer values are stored in sql db. Calculate (appoint) the largest surface area of ​​the flat. By 'flat area' we mean an ...
1
vote
2answers
324 views

How fast should a Python factoring script be?

Just how efficient is "good enough" for all intents and purposes? I wrote a script to simply list off all numbers that divide into an input, x, as pairs (i, n//i) and was just curious how efficient I ...
5
votes
5answers
3k views

Can anyone help solve this complex algorithmic problem?

I got this question in an interview and I was not able to solve it. You have a circular road, with N number of gas stations. You know the amount of gas that each station has. You know the amount of ...
5
votes
2answers
776 views

difference between accounting and potential methods in Amortized Analysis

I was going through the Introduction to Algorithms by Cormen et al.In the chapter titled Amortized Analysis,the difference between accounting and potential methods is given like this The ...
1
vote
1answer
349 views

What are some algorithms that can assist with reservation time scheduling?

Here's the gist of the problem: There are multiple service providers who each have their own schedules of availability. There are multiple customers who seek their services. Customers need to be able ...
28
votes
8answers
3k views

What is beautiful code? [closed]

I often read that developers must write beautiful code, but for a beginner as I am it remains obscure of what is beautiful code and how do you recognize it? The corollary question is: How to write ...
8
votes
1answer
278 views

Match two strings but allow for a degree of error

How can I match two strings, but at the same time allow for X number of characters to be incorrect in the match. The number of errors should be a controllable variable. While X number of characters ...
0
votes
1answer
231 views

Finding all points that are located in one line in 2D coordinate system

I have an array of points. Each point has two members - x and y. I want to get any 3 points and check, are they located in single line in 2D coordinate system. For example - 1x2, 2x3, 5x6: If ...
0
votes
1answer
1k views

Convert Algebraic Expression directly into Binary Tree Structure (sans prefix / postfix)

I am looking all over internet to find a logic to convert an Algebraic Expression into a Binary Tree. I could only find ones where you first convert the algebra expression to postfix or prefix and ...
3
votes
2answers
89 views

Quickly prune and create valid data combinations

I am really struggling with a problem where I need to "prune" down available scenarios to those that a user has defined as valid. Below is a small example of the problem I am trying to solve in .Net ...
0
votes
1answer
222 views

Why no gender recognition studies are performed yet to recognize gender without seeing (based on behavior)? [closed]

Each website has visitors, and each visitor might be a potential customer (lead), thus it's really good to do whatever a marketer can do to attract that lead and turn it into a real customer. ...
-2
votes
1answer
607 views

using ant colony algorithm to create cross word game [closed]

I have difficulty to learn about ant colony algorithm (ACO), I have read about generating crossword game using (genetic algorithm) GA.I Know both of GA ant ACO usually used for optimization, but my ...
1
vote
1answer
1k views

Find index of item closest to value, but is also less than value

Let's say I have a sorted array of ints like so: int[] numbers = new[] { 10, 20, 27, 30, 55, 70 }; What is the most efficient way, given a value, to find the value in that array (or the index of ...
0
votes
4answers
146 views

Big-O of this algorithm?

How can I describe the growth function in terms of n for the following algorithm? What is the bounding function (the Big-O)? Is it O(n^3)? for(i = 0 to n - 1) { c = i + 1 for(j = c to n) ...
2
votes
5answers
456 views

Find pattern in a string

How would one approach the following question: We have two strings: a normal alphanumeric string and a pattern string. the pattern string can be composed by alphanumeric chars plus the char "?" and ...
4
votes
1answer
269 views

British royal succession algorithm

I was reading about the rules for royal succession of the British monarchy and thought the easiest way I could understand it is with code (or pseudo-code). I came up with this (in a C# like ...
5
votes
2answers
1k views

What is this algorithm for converting strings into numbers called?

I've been doing some work in Parsec recently, and for my toy language I wanted multi-based fractional numbers to be expressible. After digging around in Parsec's source a bit, I found their ...
14
votes
10answers
1k views

Find out whose turn it is to buy the croissants, accounting for possible absences

A team has decided that every morning someone should bring croissants for everybody. It shouldn't be the same person every time, so there should be a system to determine whose turn it is next. The ...
0
votes
1answer
180 views

Should an algorithm handle invalid inputs and can it have hard-coded paths for certain input data? [duplicate]

I have certain preconditions on input data and I need to design an algorithm for that data. Should I also handle invalid preconditions? Also is it normal that my algorithm will work only for a ...
5
votes
3answers
1k views

random unique pair numbers from two range

I want to write a function that return random unique pair numbers every time call it from a range until resetting it. Something like this: function randomUniquePairs($ranges, $reset = false){ if ...
0
votes
0answers
101 views

Algorithm to analyse and predict

I'm having a set of data's, say Question, Question's Main Category,Main Category followers, Question's Related Categories,Each Related Categories followers, Whether it got answer in 24hrs [Yes/No] ...
20
votes
9answers
7k views

Are algorithm questions good interview questions? [closed]

I've had an argument recently with a fellow programmer. He was interviewing for a new position and was asked this question: Give a sequence of numbers starting at X and ending in Y but with one ...
10
votes
1answer
470 views

Functional Reactive/Relational Programming – Is there a difference?

I've been using Reactive Cocoa (by GitHub), a Functional Reactive Programming API for use with the Cocoa libraries for a while now, but have just read "Out of the Tar Pit", the paper that supposedly ...
0
votes
0answers
183 views

Performance of a Skip-List algorithm

Here is a simple code for a randomized skip-list: Coin_Side flip() { if ( random() % 2 == 0 ) return HEADS; else return TAILS; } Note: random() returns an integer that uses ...
6
votes
6answers
5k views

Why is binary search,which needs sorted data, considered better than linear search?

I have always heard that linear search is a naive approach and binary search is better than it in performance due to better asymptotic complexity. But I never understood why is it better than linear ...
0
votes
0answers
86 views

data stored in dbase (application result dd.mm.yyyy)

I have a .dbf file (dbase) with data of type "date" to read directly via php. I have the application result (format: dd.mm.yyyy) and the stored hex code. I can't interpret the hex data to get the same ...
26
votes
9answers
7k views

How to check if 4 points form a square?

Assume I have 4 points (they are 2-dimension), which are different from each other, and I want to know whether they form a square. How to do it? (let the process be as simple as possible.)
-1
votes
2answers
465 views

Common and frequently used algorithms of Data structures? [closed]

I have been programming for a while, and the edge that I am missing over other programming is algorithms. I know what is linked-list and binary tree, but I dont know many more of them. I failed on 2 ...
3
votes
1answer
195 views

Processing every leaf under a node in a tree efficiently

Short version: In a tree (non-binary) with many levels of children, where each node can have multiple leaves, what is the best way to tally leaves that meet a certain condition given a node? Long, ...
1
vote
1answer
162 views

What is the name of this array transformation?

Start with an array of arrays; in this case, they are different lengths in order to demonstrate the technique, but they do not have to be. [[1,2,3,4], [5,6,7], [8,9,10], [11,12,13,14,15]] At the ...
5
votes
1answer
212 views

Bin sorting problem - Please help categorize

I have a problem I am developing a solution for and currently I solve it with a brute force solution that checks all possibilities. It works for small numbers of bins but I'd like to work with a ...
0
votes
2answers
438 views

How do you come up with algorithms?

I picked up some Project Euler questions today and decided to find more effective ways to Answer the questions l had already answered. So on the question about finding the sum of the even Fibonacci ...
18
votes
2answers
961 views

What class of problem is this, and what math do I need to know to solve it?

Mushroom cultivation requires fairly precise chemical composition of substrate (a.k.a. growing medium). Let's pretend we're growing shitakes and that this is the required composition of their ...
10
votes
11answers
8k views

What is an algorithm?

What exactly is an algorithm, as in what does Algorithm mean? The little I understand the word, is that it's not specific to a particular language, or design pattern, rather it's one the most basic ...
4
votes
2answers
319 views

Do Tech Firms use a lot of Algorithmic Practices that we studied in college? [closed]

I am yet to start my career, I have a profound interest in algorithm design. I somehow fail to understand that, how would a tech firm use the algorithmic paradigm? I mean in real life projects do we ...
2
votes
2answers
677 views

Optimize Reading of Multiple files

I have a unique problem which I'm hoping someone can assist with. I have One big text file, our Production file. The data in the file is delimited in the following format Reference|Cost ...
3
votes
2answers
609 views

Text search - big data problem

I have a problem I was hoping I could get some advice on! I have a LOT of text as input (about 20GB worth, not MASSIVE but big enough). This is just free text, unstructured. I have a 'category ...
6
votes
3answers
247 views

How can degree of order in a list be measured?

The following questions gave me food for thought: Efficient way to shuffle objects I'd like to write an "ultimate shuffle" algorithm to sort my mp3 collection When you sort a list - ...
5
votes
2answers
357 views

Structuring Access Control In Hierarchical Object Graph

I have a Folder entity that can be Moderated by users. Folders can contain other folders. So I may have a structure like this: Folder 1 Folder 2 Folder 3 Folder 4 I have to ...
0
votes
3answers
167 views

Suggestion for a Non-CSE developer [closed]

Due to financial problems, I couldn't go for CSE in my country and had to settle for a BCIS honors degree. Now, after quite some time, when I want to go for a higher position in software development ...
17
votes
4answers
5k views

Return random `list` item by its `weight`

I have, for example, this table +-----------------+ | fruit | weight | +-----------------+ | apple | 4 | | orange | 2 | | lemon | 1 | +-----------------+ I need to return random ...
1
vote
2answers
90 views

Fair 2-combinations

I need to fairly assign 2 experts from x experts (x is rather small - less than 50) for every n applications, so that: each expert has the same number of applications (+-1); each pair of experts ...