Minimum IP subnet to transfer to another datacenter or country


Suppose I live in a country which is a member of RIPE Inc and I have purchased three /24 subnets class C.
1- Can I break the firs… | Read the rest of

algorithms – How can I make the variance of a multiple sum of set of fixed number of variables minimum?

Here is the problem:

There are $MN$ people, where there are $M$ seeds and $N$ people are in each seed.
We have to make a team of $M$ people where everyone in the team have different seeds.
Each person have their own value; the seeds are aligned so that for any seeds $I$ and $J$ and for any $ain I$ and $bin J$, $a<b$ or $a>b$ holds. Assume there are no two people with same values.

  1. People assign individually.
  2. People may assign individually or as a couple. In the latter case these two should be in the same team.

For each cases, design an algorithm to make the variance of the sum of each teams to be minimum.

Well, the problem above is the optimal solution, and since it is NP (complete?), I would accept heuristics.
I hope that the heuristic method gives the solution with variance at most $25%$ larger than the optimal solution, as I don’t want to harm the balance of the team.

Could you please give an algorithm or heuristic that can solve this problem? Also, adding a time complexity would be highly appreciated! Thanks!

Edit: All values of each person are positive integers.

algorithms – Minimum sum of squared Euclidean distance between two arrays

Given two sorted sequences in increasing order, $X$ and $Y$. $Y$ is of size $k$ and $X$ is of size $m$.
I would like to find a subset of $X$, $i.e$, $X’$ of size $k$, and considering the following optimization problem:$$d(Y,X’) = sum_{j=1}^{k}(y_{j}-x’_{j})^{2}$$ And $X’$ is a subset of $X$ of size $k$, $y_{j} text{ and } x’_{j}$ is element in $Y$ and $X’$. I would like to find the subset of $X$, to reach the minimum of $d(Y,X’)$.
Note that $X’$ could have $k!$ numbers of arrangements, so its order is totally unknown.

What I have came up with so far:
I would like to approach it using Dynamic Programming, and I think I would first compute the squared distance between each element in $Y$ and $X$, but I’m having trouble in determining what is the subproblem and how to solve ths using DP. Thank you!

Minimum size of regular graph with no short cycles

For $d geq 3$ (degree) and $r geq 3$ (radius), say that a $d$-regular (finite, simple, non-oriented) graph $G$ is $r$-almost-tree if it contains no cycle of length $leq 2 r$: in other words, we want our graph to look locally like a $d$-regular tree, in the sense that its restriction to any ball of radius $r$ always has exactly the (local) structure of a $d$-regular tree. Denote by $N(d, r)$ the minimum possible of vertices for a $r$-almost-tree $d$-regular graph. What can one tell about $N(d, r)$?

A first observation is that $N(d, r)$ is always finite. (Proof: For $n$ large, consider $d$ random involutions without fixed point of $mathfrak{S}_{2 n}$; then the Cayley graph of the subgroup that they generate will be $r$-almost-tree with a probability tending to $1$ as $n to infty$). But what about sharp upper bounds? In particular, a trivial lower bound on $N(d, r)$ is given by the size of a ball of radius $d$ in a tree, i.e. $1 + d + (d – 1) d + cdots + (d – 1)^{r – 1} d =: N_0(d, r)$. In view of this, two natural questions are the following:

  • In which cases does one have $N(d, r) = N_0(d, r)$? In particular, for fixed $d$, are there intinitely many $r$‘s such that $N(d, r) = N_0(d, r)$? (Note: I investigated the case $d = 3$: then $r = 1$ and $r = 2$ fit, but not $r = 3$ nor $r = 4$).
  • For fixed $d$, is the ratio $N(d, r) / N_0(d, r)$ bounded as $r$ tends to infinity?…

java – Prim’s algorithm via Priority Queues to print the minimum spanning tree of an adjacency matrix undirected graph

My adjacency matrix looks like this, where non-zero weights denote edges.

(0, 2, 0, 0, 3)

(2, 0, 2, 4, 0)

(0, 2, 0, 3, 0)

(0, 4, 3, 0, 1)

(3, 0, 0, 1, 0)

//nested class, only showing the relevant parts of code
class Edge implements Comparable<Edge> {
    int source;
    int destination;
    int weight;

    public Edge(int source, int destination, int weight) {
        this.source = source;
        this.destination = destination;
        this.weight = weight;

    public String toString() {
        return source + "---" + weight + "---" + destination;

    public int compareTo(Edge other) {
        return, other.weight);

public void printPrimsMST(int()() matrix) {
    // Start with any vertex.
    Set<Integer> visited = new HashSet<>();
    Queue<Edge> edgeQueue = new PriorityQueue<>();

    int currentNode = 0;
    while (visited.size() < matrix.length) {

        for (int col = 0; col<matrix(currentNode).length; col++) {
            // Take all edges from this node.
            if (col == currentNode || matrix(currentNode)(col) == 0) {
                //skip self as well as 0-weight edges.
            edgeQueue.add(new Edge(currentNode, col, matrix(currentNode)(col)));

        if (edgeQueue.isEmpty())

        //find cheapest edge to a not already visited destination.
        Edge edge = edgeQueue.remove();
        while (visited.contains(edge.destination)) {
            if (edgeQueue.isEmpty())
            edge = edgeQueue.remove();

        System.out.println(edge.source + "--" + edge.weight + "--" + edge.destination);
        // Now that you've reached this edge as a destination, record it.
        currentNode = edge.destination;

Prim’s algorithm via Priority Queues to print the minimum spanning tree of an undirected graph

Here’s my attempt, I believe the runtime is O(V*(ElogE + log E)) since the while loop runs V times and it takes ElogE + log E to do the priority queue operations inside the loop.

class Edge implements Comparable<Edge> {
  T source;
  T destination;
  int weight;

  public Edge(T source, T destination, int weight) {
     this.source = source;
     this.destination = destination;
     this.weight = weight;

  public int compareTo(Edge other) {
    return this.weight - other.weight;

public void printMSTPrims(Map<T, List<Edge> > adjacencyList) {
        // Records all visited destinations.
        Set<T> visited = new HashSet<>();
        Queue<Edge> edges = new PriorityQueue<>();
        T currentNode = adjacencyList.entrySet().iterator().next().getKey();
        // Run until we've visited all vertices
        while (visited.size() < adjacencyList.size()) {
            // Take all edges from current node and add to the PQ.
            for (Edge edge: adjacencyList.get(currentNode)) {

            // Pick the smallest edge to a destination node not already visited.
            Edge edge = edges.remove();
            while (!edges.isEmpty() && visited.contains(edge.destination)) {
                edge = edges.remove();

            // Found an eligible edge, print its contents. This edge does not have to necessarily start from the currentNode.
            System.out.println(edge.source + "--" + edge.weight + "--" + edge.destination);
            // Go next to this destination vertex.
            currentNode = edge.destination;

            //Now that you've reached this edge as a destination, record it.


computer networks – Calculating minimum frame size

I’m actually quite stuck on a question I have for an assignment…I’d appreciate any help with this:

Consider a CSMA/CD network with maximum cable length of 8km and where the ratio of propagation speed to bandwidth (i.e. propagation speed/bandwidth) is 10 meters per bit. What is the minimum frame size in bytes?

I know that frame size, S >= 2BL where B is bandwidth, and cable length is L but I can’t quite get it done.

linear algebra – The minimum number of polynomial equations the components of linearly dependent vectors must satisfy

This questions might be really stupid. So I apologize beforehand. Here I go:


Consider $m<n$ vectors $v_1,dots,v_minmathbb{C}^n$ with complex components. We can study if they are linearly dependent by constructing the following matrices. First the $ntimes m$ matrix $A=(v_1,dots,v_m)$ and the $ntimes n$ matrix $B = (A,w_1,dots,w_r)$ where $w_1,dots,w_rinmathbb{R}^n$ are $r=n-m$ arbitrary vectors. The vectors $v_1,dots,v_m$ are linearly dependent if and only if $B$ is singular for every choice of $w_1,dots,w_r$. Equivalently, if $text{det} B=0$. Expanding the determinant in minors we get
text{det }B = sum_{alphainmathcal{A}}q_alpha(w_1,dots,w_r)text{det}A_alpha

where $mathcal{A}={1,dots,n}^{m}$, $A_alpha$ is the submatrix of $A$ of size $mtimes m$ with rows of $A$ marked in $alphainmathcal{A}$, and $q_alpha$ are some polynomials in the components of $w_1,dots,w_r$. Hence, to obtain $text{det} B=0$ for any $w_1,dots,w_r$ one need to have $text{det} A_alpha=0$ for all $alphainmathcal{A}$. Correct me if I’m wrong (maybe I’m not counting correctly), but there are ${n choose m} = frac{n!}{m!(n-m)!}$ equations of the form $text{det} A_alpha=0$. However, the set of vectors $v_1,dots,v_m$ have $nm$ (independent) components. Hence, for a set of $m$ vectors to be linearly dependent, their $nm$ components must satisfy $frac{n!}{m!(n-m)!}$ equations. Its easy to verify that for many pairs $n,m$ (for instance $n=6$ and $m=3$) there are more equations than possible variables.

If these were arbitrary polynomials, it wouldn’t be possible to get linearly dependent vectors in general for such pairs $n,m$; however linearly dependent vectors do exist. Therefore, many of these polynomials must be dependent in some way. In fact, if we consider only $mtimes m$ submatrices in which the chosen rows were consecutive in $A$, we obtain $n-m+1$ equations which are independent, since every one of them introduces a a new set of variables (a whole new row of $A$) with respect to the previous ones. However, it is not clear to me if there are more of equations from all possibilities which are independent too.

Question: In general, what is the least number of equations of the form $text{det} A_alpha=0$ that the components of the set of vectors $v_1,dots,v_minmathbb{C}^n$ must satisfy?

Or equivalently how many equations of the form $text{det} A_alpha=0$ are independent.

greedy algorithms – Computer Science – minimum cover intervals in a susbset

Hi I’ve been going about this problem for day and cant seem to understand how will I solve this?

Canon is faced with a set A of n intervals on the real line. He is looking for a subset of
these intervals B ⊆ A, called a covering, where the intervals in B cover the intervals in A
(i.e., every real value in some interval in A is contained in some interval in B ). The size of
a covering is the number of intervals in the covering. Pikachu wants the minimum cover
Bmin: the covering with the smallest possible size. Assume Canon’s input consists of
two arrays AL(1..n) and AR(1..n), representing the left and right endpoints of the intervals
in A.
Describe a greedy algorithm to compute Bmin in O(n log n) time. Explain your code. Hint:
Start with the left-most interval. Explain why this algorithm runs in O(n log n) time.

Start your own white label HYIP business at minimum cost – HYIPs

Start your own white label HYIP business with attractive functionalities. ECHYIP offers its HYIP Script at exclusive prices. Along with the script, they provide free installation and dedicated tech support. Get combo packages and attractive deals on crypto scripts by visiting now at the ECHYIP website. A free demo is available on the website so check it to understand the features of it.