For fun I'm learning about graph theory and I came across this problem. Given a set of vertices V, a set of edges E, and a weight for each edge in E, how can I efficiently construct a graph G such that:
G is connected (all vertices are connected via some path)
the sum of the weights of the edges is minimized
Cheers!
Edit: the edge...
Recently, I have taken interviews and found that many of the questions are related to algorithms and math problems.
I think that there are lots of things that are important other than algorithms, such as experience, domain specific knowledge, basic OS/compiler knowledge, etc..
Why do they ask so many algorithmic problems?
...
I've just now started reading an Algorithms book that defined Graphs as follows:
Graphs – which represent relationships
between arbitrary pairs of objects.
Figure 1.8(b) models a network of
roads as a graph, where the vertices
are cities and the edges are roads
connecting pairs of cities. Graphs are
likely the object in q...
Hi! I have to make a method for making a list with all the paths in a graph.My graph has only one start node and one finish node. Each node has a list whith its children and other list whith its parents. I have to make another list containing all the paths (each of them in another list)
Any suggestion??
...
I have read an article about various shuffle algorithms over at Coding Horror. I have seen that somewhere people have done this to shuffle a list:
var r = new Random();
var shuffled = ordered.OrderBy(x => r.Next());
Is this a good shuffle algorithm? How does it work exactly? Is it an acceptable way of doing this?
...
I've written an algorithm that I believe to be correct for computing prime numbers up to n with the Sieve of Eratosthenes. Unfortunately, this program hangs on really large values of n (try 10 million). Here is what I've written...
Protected Function Eratosthenes(ByVal n As Integer) As String
Dim maxValue As Integer = Math.Sqrt(n)...
I have a given number of boxes in a specific order and a number of weights in a specific order. The weights may have different weights (ie one may weigh 1kg, another 2kg etc).
I want to put the weights in the boxes in a way so that they are as evenly distributed as possible weight wise. I must take the weights in the order that they are ...
I've come across MANY AR libraries/SDKs/APIs, all of them are marker-based, until I found this video, from the description and the comments, it looks like he's using SIFT to detect the object and follow it around.
I need to do that for Android, so I'm gonna need a full implementation of SIFT in pure Java.
I'm willing to do that but I n...
I apologize for being a bit verbose in advance: if you want to skip all the background mumbo jumbo you can see my question down below.
This is pretty much a follow up to a question I previously posted on how to compare two 1D (time dependent) signals. One of the answers I got was to use the cross-correlation function (xcorr in MATLAB), ...
Hi.
I have an image on a polar grid. This image should be transformed into a cartesian grid, but the only algorithm I know of is really slow for this. Now I use the cartesian grid, for each point I find the r and theta values, and then I look in two vectors to find the smallest error defined by:
min{(th_vec - theta)^2 + (range - r)^2}
...
Assuming a collection of objects, each of which needs to be drawn at a specific layer, at what point would it (or ever) be better to sort each object by layer rather than looping multiple times and drawing a layer at each pass? More importantly how would you arrive at this conclusion? Bonus points for a sort algorithm you would use if ...
I have a lot of compound strings that are a combination of two or three English words.
e.g. "Spicejet" is a combination of the words "spice" and "jet"
I need to separate these individual English words from such compound strings. My dictionary is going to consist of around 100000 words.
What would be the most efficient by which I...
Hi!!
I am having some trouble to achieve this little round robin project. What i try to do is to generate a preview calendar of games
then I want to output;
day 1:
Team 1 vs Team 2;
Team 3 vs Team 4;
Team 5vs Team 6;
day 2
Team 1 vs Team 4;
Team 6 vs Team 3;
Team 2 vs Team 5;
till the end of the championship;
Here is the code i've ...
Why does STL work with a comparison function that is strict weak ordering? Why can't it be partial ordering?
...
What's the difference between backtracking and depth first search?
...
I have a large AVL Tree which I build some times during program from an unsorted collection (it will be used to insert/remove items later).
Is there any better algorithm than using the simple insert on each item? Will it be more efficient to sort the collection first and then try to build it differently?
Profiling of my application t...
What would be your approach to creating a home page like the new facebook 3.0 app has to offer? There's a grid of 3x3 UIButtons it appears if you look here:
If you wanted to replicate a similar user interface, would you programmatically have 9 individual buttons that you place on the screen through some kind of loop? If so what would ...
The Banker's algorithm is used to determine if all requests for resources can be satisfied without leading to a deadlock.
m is the total number of resources types
n is the total number of processes
NEED is an array of size m * n, it defines pending requests for each resources type. E.g.: NEEDij = 2 means that process i is requesting f...
Do you know of a method for quickly filtering a list of strings to obtain the subset that contain a specified string? The obvious implementation is to just iterate through the list, checking each string for whether it contains the search string. Is there a way to index the string list so that the search can be done faster?
...
Hi!
I have 2 texts (max 4000 characters) of different length. And I need to get a similarity rate based on (partial-)paraphrasing. Please note that same portion of texts can be in different position in each text (So Levenshtein is not the solution).
The comparison process should also:
not increase expo. with text size
be performance ...