algorithm

How to know when Big O is Logarithmic?

My question arises from the post "Plain English Explanation of Big O". I don't know the exact meaning for logarithmic complexity. I know that I can make a regression between the time and the number of operations and calculate the X-squared value, and determine so the complexity. However, I want to know a method to determine it quickly on...

Looking for pseudo code for hashing algorithms (open, chaining and multiple)

Greetings, I am looking for the pseudo code for "open", "chaining" abd "multiple hashing" algorithms. Yes I have been searching for a good amount of time at google but I wasn't able to get something good. If you have a link to share, I will be greatful regards ...

Sorted Combination of Multiple Lists

Consider L1, L2, L3 as lists containing n1, n2 and n3 integers in sorted order respectively. Task is to construct a sorted list L such that, L[0] = L1[0] + L2[0] + L3[0] L[i] = L1[i1] + L2[i2] + L3[i3] L[n1 * n2 * n3] = L1[n1] + L2[n2] + L3[n3] But n1, n2, n3 are very large and therefore L cannot be constructed in one go and then s...

Good refresher course on 'O(N)' type stuff?

Learned all about computing algorithm costs in College, but that was so long ago I forgot it all. Is there any sort of walkthrough that goes over the whole subject matter? I feel as though there was more than I currently remember. I want to refresh some of my core skills. ...

How to convert UTM coordinates to Latitude and Longitude?

Duplicates: How do I convert coordinates to a Latitude & Longitude? How to convert from UTM to LatLng in python or Javascript2 My current project is interfacing with a central geocoding service published by the local city planning department. The service is designed primarily for surveying, and as such returns coordinates in a UTM X...

Algorithm for data filter

Can you suggest me an algorithm for filtering out data. I am using javascript and trying to write out a filter function which filters an array of data.I have an array of data and an array of filters, so in order to apply each filter on every data, I have written 2 for loops foreach(data) { foreach(filter) { check data with filt...

Iterative tree walking

It's been quite a while since I took data structures and algorithms in college, so I was surprised recently by a suggestion that recursion may not be the way (tm) to do tree traversal. For some reason iterative, queue based traversal has not been a technique that I've ever used. What, if any, are the advantages of iterative vs. recursiv...

Listing all permutations of a string/integer

A common task in programming interviews (not from my experience of interviews though) is to take a string or an integer and list every possible permutation. Is there an example of how this is done and the logic behind solving such a problem? I've seen a few code snippets but they weren't well commented/explained and thus hard to follow...

Most efficient algorithm to generate a site map?

..given an URL as input (C programming language). (Sitemap specifications from sitemap.org). ...

Can you write a permutation function just as elegantly in C#?

I like this 6 line solution a lot and am trying to replicate it in C#. Basically, it permutes the elements of an array: def permute(xs, pre=[]): if len(xs) == 0: yield pre for i, x in enumerate(xs): for y in permute(xs[:i] + xs[i+1:], pre + [x]): yield y ...

Best Hash function for detecting data changes?

We have a pricing dataset that changes the contained values or the number of records. The number of added or removed records is small compared to the changes in values. The dataset usually has between 50 and 500 items with 8 properties. We currently use AJAX to return a JSON structure that represents the dataset and update a webpage usi...

Predict next event occurrence, based on past occurrences

I'm looking for an algorithm or example material to study for predicting future events based on known patterns. Perhaps there is a name for this, and I just don't know/remember it. Something this general may not exist, but I'm not a master of math or algorithms, so I'm here asking for direction. An example, as I understand it would be ...

Is a closed polygonal mesh flipped?

I have a 3d modeling application. Right now I'm drawing the meshes double-sided, but I'd like to switch to single sided when the object is closed. If the polygonal mesh is closed (no boundary edges/completely periodic), it seems like I should always be able to determine if the object is currently flipped, and automatically correct. Be...

How can I check for average concurrent events in a SQL table based on the date, time and duration of the events?

I have a set of call detail records, and from those records, I'm supposed to determine the average concurrent active calls per system, per hour (at a precision of one minute). If I query 7pm to 8pm, I should see the average concurrent calls for the hour (averaging the concurrent calls for each minute) within that hour (for each system). ...

Calculating the contours of a 3D heightmap?

I am looking for a function or example to produce a list of lines representing contours at a specific height within a heightmap. Eg, Lines[] = GetContours(Heights[512,512], HeightValue) Where Heights is a 512x512 array of floating point values, HeightValue is the height at which the contour should be drawn. Heights may contain multip...

Programming Riddle: How might you translate an Excel column name to a number?

I was recently asked in a job interview to resolve a programming puzzle that I thought it would be interesting to share. It's about translating Excel column letters to actual numbers, if you recall, Excel names its columns with letters from A to Z, and then the sequence goes AA, AB, AC... AZ, BA, BB, etc. You have to write a function th...

Collection of well defined abstract programming tasks

I'm looking for a site or book or any other source of tiny programming tasks one can implement in preferred language. Would be great if examples are present too. And would be superb if there're people who may review my code. May be there's a wiki of such tasks. I've tried to google, but found nothing that suits my needs. I want to impro...

Implementation of Prim's Algorithm

For my CS class I need to implement Prim's algorithm in Java and I am having problems with the priority queue step. I have experience with priority queues and understand they work in general but I am having trouble with a particular step. Prim(G,w,r) For each u in V[G] do key[u] ← ∞ π[u] ← NIL key[r] ← 0 Q ← V[G] ...

Is there a better way in C# to round a DateTime to the nearest 5 seconds?

Hi all, I want to round a DateTime to the nearest 5 seconds. This is the way I'm currently doing it but I was wondering if there was a better or more concise way? DateTime now = DateTime.Now; int second = 0; // round to nearest 5 second mark if (now.Second % 5 > 2.5) { // round up second = now.Second + (5 - (now.Second % 5));...

Finding multiple indexes from source string

Hello, Basically I need to do String.IndexOf() and I need to get array of indexes from the source string. Is there easy way to get array of indexes? Before asking this question I have Googled a lot, but have not found easy solution to solve this simple problem. ...