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)

5
votes
6answers
465 views

Can I use publicly mentioned algorithms for writing programs?

I want to write a program that solves sudoku. So, I found some sudoku algorithms on Wikipedia. Can I use them or do I need to develop my own algorithm? Also, do I need to ask the specific license ...
3
votes
1answer
421 views

Did eastern PKUFFT algorithm beat FFTW3 (Fastest FFT on the west) 20 fold?

I wonder if PKUFFT is Chinese algorithm/library and is it really better than FFTW, MKL? Edit: I will elaborate. My personal programmers interest is in fast parallel algorithms like FFTW3, which was ...
22
votes
4answers
22k views

Prerequisite math skill for Introduction to Algorithms (CLRS) book [closed]

I already have knowledge about basic algorithms. Now I plan to study more advance algorithms and I decide to go with Introduction to Algorithms. I'm not sure, do I need to refresh my math's skill ...
9
votes
1answer
1k views

How to document an algorithm properly with sample data?

I am wondering what should an algorithm documentation contain? Can't locate a proper guideline to follow. I have in mind to include summary of the algorithm description of the algorithm flowcharts ...
10
votes
2answers
4k views

Designing authentication for REST API

I'm working up an API for a REST service that I'm going to both be producing and consuming. I've spent the past few days trying to figure out how to handle authentication nicely, and think I've ...
7
votes
2answers
5k views

Is this a valid smartphone CPU vs. desktop CPU speed comparison (Android G1 vs. old Pentium 4 desktop)?

I am trying to estimate speed differences when creating code on my desktop PC that will be ported to Android phones. I don't need to be exact, but a good estimation will help stop me from creating ...
4
votes
10answers
1k views

Does it make sense to ask, “What is the difference between Design Pattern and Algorithm?”

From Wikipedia: In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. In software ...
2
votes
1answer
364 views

Most efficient way of finding entities in a grid?

I'm working on my first game; a tower defense. So far It's coming along nicely. The only issue I am having (so far) is I can't figure out a way to effciently discover if an entity has entered a towers ...
6
votes
4answers
349 views

What are some common algorithm optimization opportunities - mathematical or otherwise

What are some common algorithmic optimization opportunities that everyone should be aware of? I have recently be revising/reviewing some code from an application, and noticed that it appeared to be ...
3
votes
2answers
897 views

Simplified knapsack in PHP

I have two instances where I'd like to display information in a "justified" alignment - but I don't care if the values are switched in order. One example being displaying the usernames of people ...
1
vote
2answers
160 views

Clarification of pseudo random number generator

I am asked to create a pseudo-random number generator using the following algorithm: The generator will generate every integer from 1 to N-1 exactly once The algorithm for N=2^n ...
11
votes
3answers
6k views

AVL Trees and the REAL world

in school we are taught how we can balance an AVL tree upon an insertion or deleting. How is this type of knowledge actually going to be useful in the real world? Can someone give an example on when ...
2
votes
1answer
150 views

Find next occurence in a Tree

Have a tree of variable depth, and width. What is the best algorithm to find the next occurence of the node in that tree. Next = Search to the right side of the tree ( as in breadth first search ) ...
8
votes
3answers
2k views

What is the best way to keep track of the median?

I read a question, and I'm looking for input on how to solve it: Numbers are randomly generated and stored into an (expanding) array, How would you keep track of the median? There are two data ...
6
votes
3answers
3k 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 ...
134
votes
14answers
8k views

Simple method for reliably detecting code in text?

GMail has this feature where it will warn you if you try to send an email that it thinks might have an attachment. Because GMail detected the string see the attached in the email, but no actual ...
11
votes
3answers
343 views

Why does the iterative version take longer?

I was looking over at http://programming.lispdream.com/blog/2011/06/recursion-vs-iteration/ and I saw that on his implementation of the recursive and iterative implementations of the factorial ...
12
votes
6answers
7k views

Can we technically un-blur images?

Since there is an algorithm to blur images, so that part of it cannot be recognised, can we reverse the algorithm and unblur part of than image? Is there a program that already does that, is that ...
4
votes
4answers
260 views

Useful Pre-requisites for Operating Systems course?

How important is knowledge of data structures and algorithms for an Operating Systems and Systems Programming course where we will be required to design and implement a kernel of a real-time operating ...
1
vote
3answers
2k views

Search for a sub-string in a given array of strings

I have an array of n strings. I want to select all the elements of the array that starts with the given string. Sorry if that is not clear. I'll give an example. input = "as" array = ["abas", ...
3
votes
3answers
4k views

What algorithms would be useful for designing a stock market simulator?

We are in the process of building a stock market simulation game. The frontend design is ready but we are clueless about how exactly the back-end algorithms are to be designed. What algorithms should ...
8
votes
6answers
926 views

Floyd's algorithm [closed]

Is it possible(expected) for an individual to figure out(having never seen it before) the algorithm if asked at an interview? What other problems have equally interesting solutions? Edit: Due to the ...
4
votes
1answer
177 views

Repeat digit problem

There are numbers 1 to N present in a list, and an additional number that has been included by mistake. So, in total there are N+1 numbers. Assume that the largest integer that the language can handle ...
2
votes
4answers
278 views

Process each row against each other, how much would it cost?

If I have n rows in a database, and I want to compare every row against each other, how many loops (or processes) would I need to do. Is it n2? (so if I have 30,000 rows then it would be 900,000,000) ...
13
votes
6answers
2k views

Is it ok to not fully understand RB Trees? [closed]

So I just learned red black trees at Cormen and wow! Typically I like to understand all algorithms and data structures to the point I can rebuild them from scratch without having to cheat looking at ...
5
votes
1answer
971 views

Coding site with test harness for basic data structures like linked list,graph,strings etc [closed]

I just took an Amazon online test and I messed it up badly. I am out of practice and have low confidence in writing code. Are there any coding sites with test harnesses for basic data structures and ...
1
vote
5answers
7k views

Is Bubble Sort the slowest sorting algorithm? [closed]

Is bubble sort the least Big-O efficient? If the answer is no, then what is the least efficient sorting algorithm?
4
votes
8answers
2k views

What do you consider to be the essential design patterns? And do you use them? [closed]

It seems to me that programmers have an increasingly uphill task of staying up-to-date. In my efforts to improve my programming ability, I am in search of the essential design patterns that are ...
8
votes
1answer
712 views

Subset sum problem is NP-complete?

If I know correctly, subset sum problem is NP-complete. Here you have an array of n integers and you are given a target sum t, you have to return the numbers from the array which can sum up to the ...
2
votes
2answers
508 views

How do we know if a problem is hardest in NP

I read that the definition of NP-complete is : These are the hardest problems in NP. Such a problem is NP-hard and in NP How do we know if a problem is hardest in NP, and no harder problem ...
7
votes
3answers
279 views

NP hard/complete

I have never been very clear on this concept. Please help: At the end of the day, we should want to identify useful problems for which we don't have polynomial solution so far and only have ...
-2
votes
7answers
3k views

Which sorting algorithms have a different worst case complexity than their average case? [closed]

I'v been working on sorting for a while now but I can't figure these two questions apart, I'm kind of getting mixed up somewhere ... Somebody help a) Which sorting algorithms have a different worst ...
16
votes
10answers
46k views

Difference between a pseudo code and algorithm?

Technically, Is there a difference between these two words or can we use them interchangeably? Both of them more or less describe the logical sequence of steps that follow in solving a problem. ain't ...
16
votes
3answers
12k views

Why isn't Radix Sort used more often?

It's stable and has a time complexity of O(n). It should be faster than algorithms like Quicksort and Mergesort, yet I hardly ever see it used.
6
votes
3answers
3k views

Is Google's Go a type-safe language?

this page http://golang.org/doc/go_faq.html writes: although Go has static types the language attempts to make types feel lighter weight than in typical OO languages So my question is ...
18
votes
4answers
1k views

Why do most languages provide a min-heap instead of a max-heap implementation?

I just noticed something and I wonder if there is any reason for that. Except for C++ (std::priority_queue is a max heap), I don't know any other language that offers a max heap. Python's heapq ...
8
votes
6answers
2k views

algorithm from scientific paper [closed]

In my application I want to use a mixture of several algorithms described in some recently published scientific papers. But I have some legal questions. Q1 If an algorithm was published in a ...
4
votes
7answers
6k views

Generating every combination of a 32 character alpha numeric string?

Is it possible to generate every possible combination of a 32 character alpha numeric string? If so, how long would it take on today's fast computers? My lecturer at university said it's impossible, ...
5
votes
3answers
714 views

All possible solutions to equation, where operators are arbitrary?

Given something like this: 1 5 3 4 = 18 I need to determine (using an algorithm) if there is a combination of operators and brackets that bring me to 18. Only "+" and "*" and "(" and ")" are ...
8
votes
10answers
2k views

A better way of doing Regex? [duplicate]

I really dislike regular expressions, each time I come back to it I seem to have to relearn it. It's also incredibly hard to maintain, modify and at a glance understand what it is doing. Has anyone ...
6
votes
2answers
662 views

Why would I care about the asymptotic growth of the lower bound of the worst case time/space?

In mathematics, there are notations for asymptotic lower bounds, upper bounds, and tight (within-a-constant-factor) bounds. When describing the growth of functions in general, it makes sense that all ...
10
votes
2answers
1k views

Ideal data structure for storing map data?

I was asked this in an interview test. I did okay on the test but didn't know enough to answer this question. I am curious to know what data structures I can use to query the data quickly. Basically ...
9
votes
5answers
5k views

How do you identify “edge” cases on algorithms?

Basically how do you find out which could be your worst or best case and any other "edge" cases you might have BEFORE having them and so, how do you prepare your code for them?
15
votes
4answers
3k views

NP complete or NP hard problems in real life

Does anybody have real life examples where they regularly solve NP complete or NP hard problems (by heuristics, or chasing a suboptimal solution or whatever) in their job? I know they occur in ...
10
votes
5answers
7k views

Most Efficient Cache Replacement Algorithm [closed]

Wikipedia lists 11 cache replacement algorithms. Assuming I know almost nothing about the application I'm going to develop, what should I use as a "default" cache replacement algorithm? If I recall ...
3
votes
2answers
1k views

What language does Introduction to Algorithms by Cormen use?

What language, if any, is used in this book? My school is currently using a terrible book for the algorithms course that I have to take next year and I'd like to convince the department head that ...
12
votes
11answers
12k 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 ...
3
votes
5answers
826 views

Is a genetic algorithm a correct approach to this problem?

I am trying to calculate a set of items that produce the highest damage output in a video game. There are about 50 different items, of which you can choose 6. There are all sorts of conditions that ...
3
votes
4answers
5k views

TEA algorithm constant 0x9e3779b9 said to be derived from golden ratio, but the golden number is 1.618?

I'm trying to understand a constant 0x9e3779b9. What kind of data is this? It's not binary, not decimal, what is this? It's a constant used on the TEA algorithm. It says it's derived from the golden ...
2
votes
3answers
281 views

Starter BOOKS On Data Analytics and Algorithms in Computer Science

Am Programmer cum Co-Founder of Start-up,Am a computer Science Graduate though am not good at Algorithms,I want to learn and sharp that side.Please suggest me some nice books for starters and Advance ...