## How to detect self loop in graph using greedy algorithm if given list of number of degrees

if you are given list of n integers that represents the degree of a graph. How to detect if there self loop in the graph using greedy algorithm.

Posted on Categories proxies

## Does Duelist’s Crippling Critical counts for the max number of crit feats used in a turn?

Imagine a character which would become a Duelist 10, focused on doing crits with his weapon. So, he would go all the way until he gets Stunning Critical. The question is:

Could the character accumulate the Stunning Critical feat power with the class ability Crippling Critical or would he need Critical Mastery for doing both? Does the class ability counts as a critical feat for this stacking purpose?

Posted on Categories Best Proxies

## Algorithm for finding an irreducible kernel of a DAG in O(V*e) time, where e is number of edges in output

An irreducible kernel is the term used in Handbook of Theoretical Computer Science (HTCS), Volume A “Algorithms and Complexity” in the chapter on graph algorithms. Given a directed graph G=(V,E), an irreducible kernel is a graph G’=(V,E’) where E’ is a subset of E, and both G and G’ have the same reachability (i.e. their transitive closures are the same), and removing any edge from E’ would not satisfy this condition, i.e. E’ is minimal (although not necessarily the minimum size possible).

A minimum equivalent graph is similar, except it also has the fewest number of edges among all such graphs. Both of these concepts are similar to a transitive reduction, but not the same because a transitive reduction is allowed to have edges that are not in E.

HTCS says that there is an algorithm to calculate an irreducible kernel of a directed acyclic graph in time O(V*e) time, where V is the number of vertices, and e is the number of edges in the irreducible kernel, i.e. the output of the algorithm. The reference given for this is the following paper, which I have not been able to find an on line source for yet (links or other sources welcome — I can ask at a research library soon if nothing turns up).

Noltemeier, H., “Reduction of directed graphs to irreducible kenrels”, Discussion paper 7505, Lehrstuhl Mathematische Verfahrenforschung (Operations Research) und Datenverarbeitung, Univ. Gottingen, Gottingen, 1975.

Does anyone know what this algorithm is? It surprises me a little that it includes the number of edges in the output graph, since that would mean it should run in O(n^2) time given an input graph with O(n^2) edges that represents a total order, e.g. all nodes are assigned integers from 1 up to n, and there is an edge from node i to j if i < j. That doesn’t seem impossible, mind you, simply surprising.

Posted on Categories proxies

## Maximum number of similar groups of a given size that can be made from a given array

I am given an array of numbers, not necessarily unique, and the size of a group. Let the array be denoted by $$B$$ and the size of the group be $$A$$.

I need to find the maximum number of groups with the exact same contents and of size $$A$$ that can be made from the elements of $$B$$. Once an element is used in a group it is exhausted. A group can have more than one element with the same value as long as the element is still available in $$B$$.

Example:

1. If the input array is $$\{1, 2, 3, 1, 2, 3, 4\}$$, and the group size is $$3$$ the maximum number of groups that can be made is $$2$$, which are $$\{1, 2, 3\}$$ and $$\{1, 2, 3\}$$.
2. If the input array is $$\{1, 3, 3, 3, 6, 3, 10\}$$, and the group size is $$4$$ the maximum number of groups that can be made is $$1$$, which is $$\{1, 3, 3, 3\}$$.

What I have tried so far, is to frame some equations ( given below ) but after that, I am struggling to come up with an algorithm to solve them.

Let $$F_1$$ be the frequency of the element $$B_1$$, $$F_2$$ be the frequency of the element $$B_2$$ and so on till $$B_n$$, where $$B_1 \dots B_n$$ are distinct elements from the array $$B$$.

Now I need to choose $$n_1, n_2, \dots n_i$$ such that

1. $$n_1 + n_2 + \dots + n_i = A$$
2. $$k\cdot n_1 \leq F_1\text{ , } k\cdot n_2 \leq F_2\text{ , }\dots \text{ , }k\cdot n_i \leq F_i$$
3. $$k$$ is the number of groups and we need to maximize it.

Length of $$B$$ can be as large as $$10^5$$ and $$A$$ can also be as large as $$10^5$$.

## How to compute the general term formula for the number of full binary tree heaps that can be formed with distinct elements?

The number of possible heaps that are full binary trees of height $$h$$ and can be formed with ($$n = 2^h – 1$$) distinct elements can be computed by recursion: $$a_h = {2^h – 2 \choose 2^{h – 1} – 1} a_{h – 1}^2$$ How to compute the general term formula with this recursion formula?

Posted on Categories proxies

## number of times a given NNTP usenet newsgroup has been visited/read since a given date [closed]

Does anyone of you know how to get the number of times a given NNTP usenet newsgroup has been visited/read since a given date ?

thank’s

Posted on Categories proxies

## Minimum number of swaps in sorting sequence

Given an array of N integer elements (not necessarily distinct), what is the minimum number of swaps (not necessarily adjacent) needed to sort the array?

I’ve been struggling with this problem for a few months now. I know that the elements are distinct, the answer is the number of cycles in the permutation obtained after normalizing the values and that if the swaps are adjacent bubble sort obtains the optimum number of swaps, but nothing about this one. This question asks the same, but the answers only consider distinct elements.

My approach to the problem is graph theoretical, considering a graph with a node for each element value, drawing an oriented edge from $$a$$ to $$b$$ whenever a value $$a$$ lies at a position where $$b$$ should lie in the sorted array ($$a \neq b$$, so no loops), the answer being the maximal (partition with most equivalence classes) partition of the edges into simple cycles (a generalization of the solution for arrays with distinct elements).

Does this problem have a known name? Any references? Any polynomial solution or complexity class ownership (P, NP, graph isomorphism equivalence etc)?

Posted on Categories proxies

## Upper bound on the average number of overlaps for an interval within a set of intervals

Let $$\mathcal{I}$$ be a set of intervals with cardinality $$L$$, where each interval $$I_i \in \mathcal{I}$$ is of the form $$[a_i, b_i]$$ and $$a_i, b_i$$ are pairwise distinct non-negative integers bounded by a constant $$C$$ i.e. $$0 \leq a_i < b_i \leq C$$. We say a pair of intervals $$I_i, I_j \in \mathcal{I}$$ overlap if the length of overlap is $$> 0$$.

Define a function $$F(i)$$ which computes the number of intervals in $$\mathcal{I} \backslash I_i$$ that interval $$I_i$$ overlaps with. $$\begin{equation} F(i) = \sum_{j=1, j \neq i}^{L} Overlap(I_i, I_j) \end{equation}$$ where the function $$Overlap(I_i, I_j)$$ is an indicator function which returns 1 if $$I_i, I_j$$ overlap, else it returns 0.

The average number of overlaps for the intervals in $$\mathcal{I}$$, denoted by $$Avg(\mathcal{I})$$ is given by $$Avg(\mathcal{I}) = \dfrac{\sum_{i=1}^{L}F(i)}{L}$$.

The question is, suppose we are allowed to choose the intervals in the set $$\mathcal{I}$$ with the following additional conditions:

1. For any $$t \in [0, C]$$, we have at most $$M$$ (and $$M < L$$) intervals in $$\mathcal{I}$$ such that $$t$$ is contained within those $$M$$ intervals. Stated differently, at most $$M$$ intervals overlap at any point in time.
2. Any interval in $$\mathcal{I}$$ overlaps with at most $$K$$ other intervals, and $$M < K < L$$.

then, what is an upper bound on $$Avg(\mathcal{I})$$ for any choice of the intervals in $$\mathcal{I}$$ satisfying 1, 2?

In case you are wondering, this problem is of interest to me in order to be able to study the run-time of a scheduling algorithm.

I am unable to come up with a non-trivial upper bound for $$Avg(\mathcal{I})$$ and would be interested to know if the problem I stated has been studied. I am also open to ideas on how one may be able to obtain a tight upper bound for $$Avg(\mathcal{I})$$.

Posted on Categories proxies

## How to approximate a large number of points – algorithm ideas

Assume there is a <0, 1> interval in 1D space with some points (nothing can be said about them). We can only use an operation of inputing a number (coordinate) and getting distances to the closest points on both sides of that given coordinate. An approximate number of all points needs to be found without counting all of them.

I need some ideas or clues on where to look for some similar problems to find an efficient algorithm.

Posted on Categories proxies

## Number of executions of the algorithm with probability about graphs

Consider an undirected graph $$G = (V, E)$$ representing the social network of friendship/trust between students. We would like to form teams of three students that know each other. The question is to decide whether the network allows for enough such teams, without checking all the triples of graph $$G$$. For this reason, we use random sampling to design an efficient estimator of the number of connected triples. We partition the set of node triples into four sets $$T_0, T_1, T_2$$, and $$T_3$$. A node triple $$v1, v2, v3$$ belongs to

• $$T_0$$ iff no edge exists between the nodes $$v1, v2$$, and $$v3$$,
• $$T_1$$ iff exactly one of the edges $$(v1, v2), (v2, v3)$$, and $$(v3, v1)$$ exists,
• $$T_2$$ iff exactly two of the edges $$(v1, v2)$$, $$(v2, v3)$$, and $$(v3, v1)$$ exist,
• $$T_3$$ iff all of the edges $$(v1, v2), (v2, v3)$$, and $$(v3, v1)$$ exist.

$$|T_3|$$ denotes the number of connected triples in the graph that is the quantity we need to estimate. Consider the following algorithm:

• Sample an edge $$e = (a, b)$$ uniformly chosen from $$E$$

• Choose a node v uniformly from $$V \setminus (a,b)$$

• if $$(a, v) ∈ E$$ and $$(b, v) ∈ E$$ then $$x = 1$$, else $$x = 0$$

This exercise about algorithms asks me to find a nontrivial number $$s$$ of executions of the algorithm which are sufficient in order to obtain an $$(1 + \epsilon)$$ and an $$(1 − \epsilon)$$ approximation of $$|T_3|$$ with probability at least $$1 − δ$$. I don’t know how to behave with the probability, could you give me some help to solve this?

Posted on Categories proxies