algorithm

Fast FEM Solvers

What are the fast solvers for FEM equations? I would prefer open source implementation, but if there is a commercial implementation, then I won't mind paying for it. ...

Where to find out the method used for excel functions

Hi all, I am looking for a source for the processing steps behind Excel functions. For example I would like to know how exactly the function PERCENTILE(array, percentile) works. Having embarked upon a quick search I couldn't find anything really, so was wondering if anyone here knew of a better source. The reason for my search is that ...

Finding difference less than the average in an unsorted array?

Hi, I need to find 2 elements in an unsorted array such that the difference between them is less than or equal to (Maximum - Minimum)/(number of elements in the array). In O(n). I know the max and min values. Can anyone think of something? Thank you! ...

How to implement a custom rating system (with a declining date relevance)

I'm working on a site similar to digg in the respect that users can submit "stories". I keep track of how many "votes" and "similar adds" each item got. Similar adds are defined as two users adding the same "link". Here is part of the algorithm (essentially the most important): y = day number sy = number of adds on day y ∑ y[1:10]...

Smooth spectrum for Mandelbrot Set rendering

I'm currently writing a program to generate really enormous (65536x65536 pixels and above) Mandelbrot images, and I'd like to devise a spectrum and coloring scheme that does them justice. The wikipedia featured mandelbrot image seems like an excellent example, especially how the palette remains varied at all zoom levels of the sequence. ...

I need to do a fill pattern in Intel hex file. My question is how would I do a fill pattern of an arbitrary size?

I have been trying to do a fill using the open source Srecord Program. The thing is I need to do a fill that is 0xC2AF00. It appears the program can only do fills that are a byte long (ex: 0xff).If this is not possible with the Srecord program, then how would I go about writing my own algorithm to do what I want. I am not quite sure ho...

How many programmers recommending "Introduction to algorithms" by CLRS actually read whole book?

All over the net I read people recommending "Introduction to Algorithms" by CLRS as a "MUST READ" for EVERY programmer, but actually, this book, although great, is not even close to being just an introduction, and recommending it to beginners is definitely totally wrong. What's your opinion on how many programmers have read the whole, o...

Binary Trees vs. Linked Lists vs. Hash Tables

I'm building a symbol table for a project I'm working on. I was wondering what peoples opinions are on the advantages and disadvantages of the various methods available for storing + creating a symbol table. I've done a fair bit of searching and the most commonly recommended are binary trees or linked lists or hash tables. I was wonderi...

How Can I Best Guess the Encoding when the BOM (Byte Order Mark) is Missing?

My program has to read files that use various encodings. They may be ANSI, UTF-8 or UTF-16 (big or little endian). When the BOM (Byte Order Mark) is there, I have no problem. I know if the file is UTF-8 or UTF-16 BE or LE. I wanted to assume when there was no BOM that the file was ANSI. But I have found that the files I am dealing wit...

Follow up: How do get some of the object from a list without Linq?

I have a question about this question. I posted a reply there but since it's been marked as answered, I don't think I'll get a response to my post there. I am running C# framework 2.0 and I would like to get some of the data from a list? The list is a List<>. How can I do that without looping and doing comparaison manually o...

Minimum CompSci Knowledge Needed for Writing Desktop Apps

Having been a hobbyist programmer for 3 years (mainly Python and C) and never having written an application longer than 500 lines of code, I find myself faced with two choices : (1) Learn the essentials of data structures and algorithm design so I can become a l33t computer scientist. (2) Learn Qt, which would help me build projects I ...

How can I form polygons from lines

I have a bunch of 2-dimensional lines, whose start and end points are known. The lines might occasionally cross each other, or one line might end in the middle of another line. I need to form polygons from this mesh of lines. If necessary, I can ensure that the left side of all lines are inside their polygons. ...

Subset summing

I have a problem related to the subset sum problem and am wondering if the differences make it easier, i.e. solvable in a reasonable amount of time. Given a value V, a set size L, and a sequence of numbers [1,N] S, how many size L subsets of S sum to less than V? This is different than the subset sum problem in three ways: I care h...

What algorithms count frequencies of common elements in a collection of sets?

I would like information on algorithms that can help identify commonality and differences between sets of overlapping data. Using stackoverflow's tag system as an example: Let's say this question has been given 5 tags. Let's say there are 1000 other questions that have at least one of these tags. Of these 1000 questions, how many of...

Algorithm to mix sound

I have two raw sound streams that I need to add together. For the purposes of this question, we can assume they are the same bitrate and bit depth (say 16 bit sample, 44.1khz sample rate). Obviously if I just add them together I will overflow and underflow my 16 bit space. If I add them together and divide by two, then the volume of e...

Is std::map + std::tr1::bind + standard algorithms worthwhile?

This is a follow-up to my question from yesterday. I have Scott Meyers' warning about write-only code on my mind. I like the idea in principle of using standard algorithms to access the keys or values of a std::map, but the syntax required is a little baroque IMHO. Let's say I want to dump all the keys of a map to a vector. Given fol...

Find the Minimum Positive Value

What's the best algorithm to find the smallest non zero positive value from a fixed number (in this case 3) of values or return 0 if there are no positive questions? My naive approach is below (in Delphi, but feel free to use whatever you like), but I think there's a more elegant way. value1Temp := MaxInt; value2Temp := MaxInt; value3T...

Sum of the digits of the number 2^1000

2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2 power of 1000 (2^1000)? Can anyone provide the solution or algorithm for this problem in java? ...

algorithm to find maximum occurence of a substring

Given a string S, what is the best algorithm to find a substring which repeats maximum number of times. For example, in "assdssfssd", it is "ss" which repeats maximum number of times. ...

How can you compare to what extent two lists are in the same order?

I have two arrays containing the same elements, but in different orders, and I want to know the extent to which their orders differ. The method I tried, didn't work. it was as follows: For each list I built a matrix which recorded for each pair of elements whether they were above or below each other in the list. I then calculated a pea...