algorithm

Dynamic Programming: Number of ways to get at least N bubble sort swaps?

Let's say I have an array of elements for which a total ordering exists. The bubble sort distance is the number of swaps that it would take to sort the array if I were using a bubble sort. What is an efficient (will probably involve dynamic programming) way to calculate the number of possible permutations of this array that will have a...

String Problem in C++

I have problem in string maniputation with c++. The Rule : if the same 'word' is repeated from sentences or paragraph i want it to become an integer. Please help me ?! example input : we prefer questions that can be answered, not just we discussed that. output: 1 prefer questions 2 can be answered, not just 1 discussed 2. 1 we 2 th...

How should I keep accurate records summarising multiple tables?

I have a normalized database and need to produce web based reports frequently that involve joins across multiple tables. These queries are taking too long, so I'd like to keep the results computed so that I can load pages quickly. There are frequent updates to the tables I am summarising, and I need the summary to reflect all update so f...

Hard Algorithm Problem: Categorizing Words and Category Values

Hi Guys, We were set an algorithm problem in class today, as a "if you figure out a solution you dont have to do this subject". SO of course, we all thought we will give it a go. Basically, we were provided a DB of 100 words and 10 categories. There is no match between either the words or the categories. So its basically a list of 100 ...

Website Search Algorithm

How does the search algorithm on stackoverflow work? I need to implement a search functionality in one of my web sites. ...

Using Traveling Salesman Solver to Decide Hamiltonian Path

This is for a project where I'm asked to implement a heuristic for the traveling salesman optimization problem and also the Hamiltonian path or cycle decision problem. I don't need help with the implementation itself, but have a question on the direction I'm going in. I already have a TSP heuristic based on a genetic algorithm: it assum...

General Address Parser for Freeform Text

We have a program that displays map data (think Google Maps, but with much more interactivity and custom layers for our clients). We allow navigation via a set of combo boxes that prefill certain fields with a bunch of data (ie: Country: Canada, the Province field is filled in. Select Ontario, and a list of Counties/Regions is filled i...

Nice PHP algorithm to convert 120000000 into '120 mil' ?

I've been struggling to find a nice algorithm to change a number (could be a float or integer) into a nicely formated human readable number showing the units as a string. For example: 100500000 -> '100.5 Mil' 200400 -> '200.4 K' 143000000 -> '143 Mil' 52000000000 -> '52 Bil' etc, you get the idea. Any pointers? ...

About: Extracting Region From Bitmap

i am trying to extract outline path from given bitmap, i create a fast algorithm (for me) on as3 and that is: //@v source bitmap's vector data //@x x to starting extraction //@y y to stating extraction //@w extraction width //@h extraction height //@mw source bitmap width //@mh source bitmap height priv...

Fast Lightweight Image Comparisson Metric Algorithm

Hi All, I am developing an application for the Android platform which contains 1000+ image filters that have been 'evolved'. When a user selects a photo I want to present the most relevant filters first. This 'relevance' should be dependent on previous use cases. I have already developed tools that register when a filtered image is ...

Most efficient sorting algorithm for a large set of numbers

I'm working on a large project, I won't bother to summarize it here, but this section of the project is to take a very large document of text (minimum of around 50,000 words (not unique)), and output each unique word in order of most used to least used (probably top three will be "a" "an" and "the"). My question is of course, what would...

Extract small relevant bits text (as Google does) from the full text search results.

I have implemented a full text search in a discussion forum database and I want to display the search results in a way Google does. Even for a very long html page only a two or three lines of the texts displayed in a search result list. Usually these are the lines which contain a search terms. What would be the good algorithm of how to...

Handling unions, subsets and supersets in Scala

I need to write a code snippet that would compare multiple arrays and produce the set that match the data in those arrays, produce the data set only in array A, but not in array B,C,D,in array B but not in A,C,D, being able to handle any number of arrays (i.e. dynamically looped). The code should utilize anonymous functions in Scala (i.e...

Search for strings matching the pattern "abc:*:xyz" in less than O(n)

Given a bunch of strings I need to find those which match 3 kinds of patterns: Prefix search - abc* Glob-like pattern - abc:*:xyz Suffix search - *xyz where * is a wildcard (and can match any number of chars). Now the straight-forward solution is just to scan every string and see if it matches the target pattern. But this is O(n). I...

PHP: Script for generating Crossword game?

I need an script for generating crossword game. I have a list of 8 words for which I wnat to generate a crossword game, let's say for 15 column and 15 row. I am not getting the concept of this problem. How to generate this using PHP ?? Can anyone tell me how to do that ?? ...

How to find average loading time for website ?

How to write a code (in any programming language, preferably in java), which calculates the average loading time of any website (including all embedded elements such as images, Javascript, CSS, etc.) ? ...

How can you walk through an integer range in an unpredictable order?

How can you loop over a fixed range of integers (say 100000-999999) in a difficult-to-predict order? assume the range may be large enough that it would be impractical to store every possible integer in an array or keep an array of every element you've found so far. you must hit every number in the range once and only once, and be able ...

Calculating the bandwidth between a client and the server?

I have an app that calls my ASP.NET page on my server, every 30 seconds. I want to use this for two purposes: Graph the uptime of my client Graph the average bandwidth from my client to the server What is the best way to calculate the bandwidth (in bytes per second) from the client to the server? I assume that I record the time, ca...

Possible NP-complete problem?

I'd just like someone to verify whether the following problem is NP-complete or if there is actually a better/easier solution to it than simple brute-force combination checking. We have a sort-of resource allocation problem in our software, and I'll explain it with an example. Let's say we need 4 people to be at work during the day-shi...

Intelligent Searching with wildcards (*) and word grouping in SQL Full-text Search

What's the best way implement MS SQL full-text search using all the normal things like wildcards and quotations. For example: If the search term the user inputs is Overdose of "Vitamin C" for child* I would like to treat "Vitamin C" as one phrase and would like to match "child" and "children" The documentation offers so many al...