Given a multiset S of size
How to check if there is a loop in link list in linear time? How to locate the right position the loop begins?
T = empty;
WHILE G has >= 1 vertex:
each vertex of G adds its lightest edge to T;
the added edges are contracted in G;
END WHILE
T = graph with only the lightest edge;
FOR i = 2 to n-1:
add to T the minimum length edge with exact one endpoint in T;
END FOR
T = empty
FOR i = 1 to n-1:
add to T the shortest edge that does not introduce a cycle;
END FOR
double sqrt(double s) {
double x = s, y = 0;
while (fabs(x - y) < 0.000001) {
y = x;
x = (x + s/x)/2;
}
return x;
}
Shift an array without only one space.
Build sufix array for string "p#t$", compare suffix 0 with its two neighbors to see if they match in length |p|.
Suppose we have a room of professors and we wish to calculate the average salary of this group. The only limitation we have, though, is that we must not allow any professor to learn any information about any of the salaries of the other professors. This includes knowing the exact value of a person's salary and knowing if this person's salary is higher or lower or equal.
Use a serial of random numbers which are generated by a single prime key.