How should I implement the classic bubble sort algorithm? I'd particularly like to see a C++ implementation, but any language (even pseudocode) would be helpful.
P.S. Not a homework.
I'm looking for an implementation preferably in Java of an algorithm for finding a Minimum Equivalent Graph of a Digraph (http://portal.acm.org/citation.cfm?id=321526.321534).
Even better would be an implementation of "Approximating the minimum equivalent digraph" http://cat.inist.fr/?aModele=afficheN&cpsidt=3634076 (requires ACM membership, sorry)
alternative link http://www.cs.umd.edu/~samir/grant/kry94b.ps (postscript)
Hello,
Knowing that we can use Divide-and-Conquer algorithm to compute large exponents, for exemple 2 exp 100 = 2 exp(50) * 2 exp(50), which is quite more efficient, is this method efficient using roots ? For exemple 2 exp (1/100) = (2 exp(1/50)) exp(1/50) ?
Hi,
In order to generate the encrypted data we would need to define a Key that should suffice generating the data. But in .net DESCryptoServiceProvider requires Key and Intialisation Vector to generate the encrypted data. In this regard, I would like to know the importance & the benefit gained by defining this initialisation vector field. Is this mandatory while encryption using DES algorithm.
Pls share your thoughts on the same.
Regards,
Balu
Just wondering if there was a nice (already implemented/documented) algorithm to do the following
Given any shape (without crossing edges) and two points inside that shape, compute all the paths between the two points such that all reflections are perfect reflections. The path lengths should be limited to a certain length otherwise there are infinite solutions. I'm not interested in just shooting out rays to try to guess how close I can get, I'm interested in algorithms that can do it perfectly. Search based, not guess/improvement based.
What's the simplest, but efficient compression algorithm?
Deflate, lzma, etc. aren't valid options. I need something that compiles really small, like: RLE, LZX, Huffman, etc..
Note: The data is 95% ASCII text
If I have a 2D array that is arranged as follows :
String X[][] = new String [][] {{"127.0.0.9", "60", "75000","UDP", "Good"},
{"127.0.0.8", "75", "75000","TCP", "Bad"},
{"127.0.0.9", "75", "70000","UDP", "Good"},
{"127.0.0.1", "", "70000","UDP", "Good"},
{"127.0.0.1", "75", "75000","TCP", "Bad"}
};
I want to know the frequency of each value .. so I27.0.0.9 gets 2. How can I do a general solution for this ? In Java or any algorithm for any language ?
I have a number of rectangles of various widths and heights. I have a larger rectangular platform to put them on. I want to pack them on one side of the platform so they spread in the lengthwise (X) dimension but keep the widthwise (Y) dimension to a minimal. That is to place them like a tetris game. There can be no overlaps but there can be gaps. Is there an algorithm out there to do this?
I've read that all stl containers provide a specialisation of the swap algorithm so as to avoid calling the copy constructor and two assignment operations that the default method uses. However, when I thought it would be nice to use a queue in some code I was working on I noticed that (unlike vector and deque) queue doesn't provide this method? I just decided to use a deque instead of a queue, but still I'm interested to know why this is?
hi,
I'm learning the IEEE paper "Monitoring the Application Layer for DDoS Attacks " .
I need to implement HSMM(Hidden Semi Markov Model) Algorithm in Java.
Please help me to do this
Given two sorted arrays: A and B. The size of array A is La and the size of array B is Lb. How to find the intersection of A and B?
If La is much bigger than Lb, then will there be any difference for the intersection finding algorithm?
I am working on an assignment where one of the problems asks to derive an algorithm to check if a directed graph G=(V,E) is singly connected (there is at most one simple path from u to v for all distinct vertices u,v of V.
Of course you can brute force check it, which is what I'm doing right now, but I want to know if there's a more efficient way. Could anyone point me in the right direction?
hello i need program which returns sum of all even number <= to given n number
for example if n=even (let say 10) sum will be 2+4+6+8+10 or if n is odd (let say 13)
2+4+6+8+10+12 please help it should be recursive algorithm
I have groups of people. I need to move groups with at least one same member as far as possible from each other.
Example:
GroupA - John, Bob, Nick
GroupB - Jack, Nick
GroupC - Brian, Alex, Steve
As you can see GroupA and GroupB overlap(they both contain Nick)
I need an algorithm to set groups as GroupA-GroupC-GroupB
Thank you
Hello,
I am working on a geographic project in Java.
The input are coordinates : 24.4444 N etc
Output: a PLAIN map (not round) showing the point of the coordinates.
I don't know the algorithm to transform from coordinates to x,y on a JComponent, can somebody help me?
The map looks like this:
http://upload.wikimedia.org/wikipedia/commons/7/74/Mercator-projection.jpg
Thank you
Hi,
I have found an implementation for dijkstras algorithm on the internet and was wondering if someone could help me understand how the code works.
Many thanks
private int nr_points=0;
private int[][]Cost;
private int []mask;
private void dijkstraTSP()
{
if(nr_points==0)return;
//algorithm=new String("Dijkstra");
nod1=new Vector();
nod2=new Vector();
weight=new Vector();
mask=new int[nr_points];
//initialise mask with zeros (mask[x]=1 means the vertex is marked as used)
for(int i=0;i<nr_points;i++)mask[i]=0;
//Dijkstra:
int []dd=new int[nr_points];
int []pre=new int[nr_points];
int []path=new int[nr_points+1];
int init_vert=0,pos_in_path=0,new_vert=0;
//initialise the vectors
for(int i=0;i<nr_points;i++)
{
dd[i]=Cost[init_vert][i];
pre[i]=init_vert;
path[i]=-1;
}
pre[init_vert]=0;
path[0]=init_vert;
pos_in_path++;
mask[init_vert]=1;
for(int k=0;k<nr_points-1;k++)
{
//find min. cost in dd
for(int j=0;j<nr_points;j++)
if(dd[j]!=0 && mask[j]==0){new_vert=j; break;}
for(int j=0;j<nr_points;j++)
if(dd[j]<dd[new_vert] && mask[j]==0 && dd[j]!=0)new_vert=j;
mask[new_vert]=1;
path[pos_in_path]=new_vert;
pos_in_path++;
for(int j=0;j<nr_points;j++)
{
if(mask[j]==0)
{
if(dd[j]>dd[new_vert]+Cost[new_vert][j])
{
dd[j]=dd[new_vert]+Cost[new_vert][j];
}
}
}
}
//Close the cycle
path[nr_points]=init_vert;
//Save the solution in 3 vectors (for graphical purposes)
for(int i=0;i<nr_points;i++)
{
nod1.addElement(path[i]);
nod2.addElement(path[i+1]);
weight.addElement(Cost[path[i]][path[i+1]]);
}
}
I am porting code from Matlab to Python and am having trouble finding a replacement for the firls( ) routine. It is used for, least-squares linear-phase Finite Impulse Response (FIR) filter design.
I looked at scipy.signal and nothing there looked like it would do the trick. Of course I was able to replace my remez and freqz algorithsm, so that's good.
On one blog I found an algorithm that implemented this filter without weighting, but I need one with weights.
Thanks, David
Hello guys,
For a school project, we'll have to implement a ranking system. However, we figured that a dumb rank average would suck: something that one user ranked 5 stars would have a better average that something 188 users ranked 4 stars, and that's just stupid.
So I'm wondering if any of you have an example algorithm of "smart" ranking. It only needs to take in account the rankings given and the number of rankings.
Thanks!
I write a sokoban solver for fun and practice, it uses a simple algorithm (something like BFS).
now i want to estimate its running time ( O and omega). but i need to know how to calculate count of paths from a vertex to another in a network. each path from a to b is a sequence of edges with no circuit.
for example this is a correct path:
http://www.imgplace.com/viewimg143/4789/501k.png
but this is not:
http://www.imgplace.com/viewimg143/6140/202.png
Hello,
Knowing that we can use Divide-and-Conquer algorithm to compute large exponents, for exemple 2 exp 100 = 2 exp(50) * 2 exp(50), which is quite more efficient, is this method efficient using roots ? For exemple 2 exp (1/100) = (2 exp(1/50)) exp(1/50) ?
In other words, I'm wondering if (n exp(1/x)) is more efficient to (n exp(1/y)) for x < y and where x and y are integers.
Is there any algorithm in c# to singularize - pluralize a word (in english) or does exist a .net library to do this (may be also in different languages)?
I have array of colors:
String s[]=new String[]{"red","black..............};
The only possible colors are red and black. I need an algorithm which partitions the array such that all red come before all black. How can I compare/exchange them to accomplish that?
•if your new element is less or equal than the current node, you go to the left subtree, otherwise to the right subtree and continue traversing
•if you arrived at a node, where you can not go any deeper, because there is no subtree, this is the place to insert your new element
(5)Root
(3)-------^--------(7)
(2)---^----(5) ^-----(8)
(5)--^
i want to add this last node with data 5...but i can't figure it out...I need a algorithm to do that
or in java language
A fast algorithm to find the size of the largest clique in a perfect graph(this one having odd cycles with at least 1 chord) with about 100 vertices ??