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)

12
votes
8answers
3k views

Find a “hole” in a list of numbers

What is the fastest way to find the first (smallest) integer that doesn't exist in a given list of unsorted integers (and that is greater than the list's smallest value)? My primitive approach is ...
4
votes
1answer
312 views

The Wikipedia animation for Maze generation using DFS isn't consistent wrt the written algorithm given there, isn't it?

Please have a look at this link: http://en.wikipedia.org/wiki/Maze_generation#Depth-first_search Here, the theoretical algorithm given is: Consider the space for a maze being a large grid of ...
3
votes
1answer
3k views

Magic square check for N×N matrix with minimum complexity

Is there any algorithm that works better than O(n²) to verify whether a square matrix is a magic one (e.g. such as sum of all the rows, cols and diagonally are equal to each other)? I did see someone ...
5
votes
2answers
10k views

Real life examples of P, NP, NP hard ,NP Complete problems [closed]

I need to know the real life or real time examples of above mentioned problems thanks!!
5
votes
5answers
2k views

Structuring database for multi-object “activity” and “following” functionalities

I am working on a web application which operate with different types of objects such as user, profiles, pages etc. All objects have unique object_id. When objects interact it may produce "activity", ...
2
votes
4answers
1k views

Is it possible to efficiently store all possible phone numbers in memory?

Given the standard North American phone number format: (Area Code) Exchange - Subscriber, the set of possible numbers is about 6 billion. However, efficiently breaking down the nodes into the sections ...
7
votes
2answers
1k views

Does LINQ require significantly more processing cycles and memory than lower-level data iteration techniques?

Background I am recently in the process of enduring grueling tech interviews for positions that use the .NET stack, some of which include silly questions like this one, and some questions that are ...
2
votes
2answers
591 views

Algorithm for creating cluster groups on two criteria

I would like to group a population based on two criteria. I will use an analogy to simplify my question. Let's say I want n number of groups. I want to populate those groups based on person's age and ...
29
votes
4answers
3k views

What's the difference between recursion and corecursion?

What's the difference between these? Recursion Corecursion On Wikipedia, there is little information and no clear code explaining these terms. What are some very simple examples explaining these ...
9
votes
4answers
3k views

Are there currently any modern, standardized, aptitude test for software engineering? [closed]

Background I am a working software engineer who is in the midst of seeking out a new contract for the next year or so. In my search, I am enduring several absurd technical interviews as indicated by ...
1
vote
4answers
146 views

Possible applications of algorithm devised for differentiating between structured vs random text

I have written a program that can rapidly (within 5 sec on a 2GB RAM desktop, 2.33 Ghz CPU) differentiate between structured text (e.g English text) and random alphanumeric strings. It can also ...
135
votes
13answers
12k views

Is it just me or is this a baffling tech interview question? [closed]

Background I was just asked in a tech interview to write an algorithm to traverse an "object" (notice the quotes) where A is equal to B and B is equal to C and A is equal to C. That's it. That is ...
1
vote
6answers
318 views

Catching an error?

Is catching an error with try ... catch a better practice than catching an error with proper analysis/error check? For instance, removing from an empty list: Does surround with a try catch clause ...
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 ...
4
votes
1answer
359 views

Inexpensive generation of hierarchical unique IDs

My application is building a hierarchical structure like this: root = { 'id': 'root', 'children': [ { 'name': 'root_foo', 'children': [] }, { 'id': 'root_foo2', 'children': [ { ...
2
votes
2answers
784 views

What's a good algorithm for a random, uneven distribution of a fixed amount of a resource?

Problem I have X, a positive integer, of some resource, R. There are N potential targets. I want to distribute all of R to the N targets in some "interesting" way. "Interesting" means: Some ...
10
votes
1answer
214 views

How do graphics programmers deal with rendering vertices that don't change the image?

So, the title is a little awkward. I'll give some background, and then ask my question. Background: I work as a web GIS application developer, but in my spare time I've been playing with map ...
8
votes
7answers
509 views

Refactoring While Programming

When posed with a problem, particularly when it is complicated in nature, I try to take some time to think about the approach I am going to take to solve the problem. Despite this, what often happens ...
1
vote
1answer
1k views

Tineye.com search algorithm?

I was wondering how does tineye carry a search. Does it store all the images and then extracts exif data? Which in turn must be stored in a database and queried against. So probably it is using some ...
8
votes
3answers
5k views

Is there any algorithm book that teaches like Head First series? [closed]

As a Java programmer I need to learn algorithms (for programming Challenges). I read some Head First Series (JAVA owned by me) and they are pretty brain friendly. So I was wondering is there any ...
1
vote
1answer
260 views

Algorithm for determining grid based on variably sized “blocks”?

I'm trying to convert a set of "blocks" in to a grid-like layout. The blocks have a width of either 25%, 33%, 50%, 66%, or 75% of their container and each row of the grid should try to fit as many ...
4
votes
2answers
650 views

What is required for a scope in an injection framework?

Working with libraries like Seam, Guice and Spring I have become accustomed to dealing with variables within a scope. These libraries give you a handful of scopes and allow you to define your own. ...
4
votes
2answers
486 views

Why hill climbing is called anytime algorithm?

From wikipedia, Anytime algorithm In computer science an anytime algorithm is an algorithm that can return a valid solution to a problem even if it's interrupted at any time before it ends. ...
14
votes
2answers
9k views

What does it mean to say an algorithm is Sound and Complete?

I heard different interpretations of sound and complete. I understand that completeness means finding a solution if there is one. What does it mean to say an algorithm is sound. What does it mean ...
4
votes
2answers
587 views

I have a stacktrace and limit of 250 characters for a bug report

I'm developing an xbox indie game and as a last-resort I have a try...catch encompassing everything. At this point if an exception is raised I can get the user to send me a message through the xbox ...
3
votes
2answers
2k views

How to prove a Dynamic programming strategy will work for an algorithm?

How can I prove that a dynamic programming (dp) strategy for a problem will work or not? For greedy algorithms, we can prove by showing the sub problems exhibits matroid property. Is there any such ...
4
votes
1answer
104 views

Suggestions to manage semi-structured email bounces?

The company I work for sends a lot of emails, and in return we get a lot of bounces. We currently don't have a good way of sorting them and help us archive the routine ones while putting the important ...
5
votes
1answer
528 views

Algorithm for perfect non-binary graph layout

I have a complex non-binary graph model. Each tree node can have multiple children&parents (a node can also have a connection to it's "brother"). A node is represented as square on screen with ...
2
votes
4answers
1k views

Resources for learning common algorithms by Lisp [closed]

Many books about algorithms and data structures are coded by imperative languages. Is there any book that can show functional programming languages can do the same thing or do them better? In ...
1
vote
1answer
2k views

Web Development Algorithms

While searching for jobs online I noticed that most PHP web developer jobs ask you to know about algorithms and data structures.While I don't know PHP yet I have started to learn it in order to obtain ...
14
votes
6answers
3k views

It takes me hours to completely understand solutions to 1000-pt problems on TopCoder. Should I get discouraged? [closed]

Sometimes this applies to the 500-pt ones too. I sometimes start feeling I will never improve enough to code them with ease like the others. Should I just quit? If not, why? It is extremely annoying, ...
1
vote
3answers
289 views

When checking for transposed day and month values between two Dates - should comparing 11/11/2000 and 11/11/2000 return true or false?

Assuming a function with a signature of boolean isTransposed(Date date1, Date date2); Example outcomes: date1 date2 Outcome 06/02/2000 02/06/2000 true 02/06/2000 06/02/2000 true ...
1
vote
2answers
711 views

In order traversal of M way Trees

If we have a 4 way tree such as the one shown below, and we do an in order traversal, what would the output of the in-order traversal be for an M-way tree? In which order would the nodes be visited? ...
2
votes
2answers
538 views

What maths should I learn to become a better computer scientist? [closed]

I'm a self taught programmer, and although I know many people feel math isn't necessary, I find that in many examples of algorithms I come across talk about (what sounds to be) some pretty complex ...
3
votes
2answers
194 views

Do Databases Optimize Queries with Sum/Average or Other Aggregates?

Imagine a database that has billions of rows with, say, payments. You need to calculate an average payment sum. That will be SELECT avg(amount) FROM payments; Now, if you need to re-calculate this ...
7
votes
11answers
2k views

Is Object Oriented stuff really that important? [closed]

For years, I have been doing Algorithmic stuff, writing scalable data structures for internet search, for example Randomized Binary Search Trees for Auto Recommendation, BitMaps, Wisdom of Crowd based ...
7
votes
12answers
1k views

How close have we gotten to automating code writing? [closed]

And I don't mean Autocomplete or automatic code snippets as inserted by modern day editors, or polymorphic code. But what is the state-of-the-art in programs that can go through given inputs and types ...
0
votes
1answer
243 views

How important is maths depending on what your coding? [duplicate]

Possible Duplicate: What does mathematics have to do with programming? How often do you have to solve pure mathematical or algorithmical problems? I heard that math can be very important in ...
0
votes
1answer
550 views

Why can't an AVL tree be recreated using pre-order traversal?

Given a binary search tree, I understand why I can use breadth-first and pre-order traversal to list the entries of the tree in such a way as to reconstruct the tree in the order in which its ...
5
votes
1answer
166 views

Use of a profiler tool to aid in the analysis of a brute force algorithm in Java

I was asked to profile (using some tool, such as YourKit or JVisualVM) a couple of implementations of the Traveling Salesman Problem (find the minimum path that visits all the given set of cities), in ...
0
votes
3answers
841 views

Program/library to match string patterns [closed]

I've city names, like Newyork. Somebody may misspell it and write it as Newyoork. I want an algorithm or library which can match such patterns with some confidence level. Any idea how to do it or if ...
34
votes
2answers
14k views

Best practice/Patterns for two way data synchronisation

Quite often in my work the idea of 2-way data synchronisation between database systems crops up. The classic example is two slightly different CRM systems (say, Raiser's Edge and Salesforce) and the ...
1
vote
2answers
1k views

What are the most known arbitrary precision arithmetic implementation approaches?

I'm going to write a class library for .NET which provide an implementation of arbitrary precision arithmetic for integer, rational and maybe complex numbers. What best known approaches should I ...
13
votes
10answers
835 views

In what areas of programming is algorithm run time actually an important issue?

Sometimes I hear people say that because of the speed of processors and the amount of memory available, algorithm efficiency and runtime aren't, in practice, of major concern. But I imagine there ...
4
votes
1answer
335 views

Website with test data files for specific algorithms/data structures?

Is there any website, like SPOJ and Project Euler, with the test data files available for specific algorithms/data structures? I know it's a fun challenge to solve those problems on your own, but I ...
3
votes
2answers
881 views

Product classifying algorithm - text classification - C# - algorithm suggestions

Alright people. Finally with the help of stackoverflow community i have gathered 20 commercial product selling websites product pages with the following features Product URL Product Price Product ...
4
votes
3answers
1k views

What function or method can I use to equally distribute a workload

This is more of mathematical question than an algorithmic one; nevertheless it will be implemented in php. I have an array of N tasks. Each task has taken t time to complete(e.g. task 1 has taken 5 ...
1
vote
1answer
323 views

Need suggestion for Mutiple Windows application design

This was previously posted in StackOverflow, I just moved to here... I am using VS2008, MVVM, WPF, Prism to make a mutiple window CRM Application. I am using MidWinow in my MainWindow, I want Any ...
8
votes
5answers
6k views

How can I extract words from a sentence and determine what part of speech each is? [closed]

I want to write something that takes a sentence and identifies each word it contains and defines what part of speech each word is. For example Hello World, I am a sentence would return this ...
7
votes
1answer
422 views

How do I efficiently store all OpenStreetMap data in an indexed way?

I have a PBF file that contains the following information about a country: Nodes, each with their own longitude, latitude and properties; used to store points in a 2D space. Ways, each with their ...