Usually, finding an exact optimal solution for an NPhard problem in practical time is difficult; it is not uncommon for such a program to run as long as months or years. Hence, heuristic or greedy algorithms are often designed to approximately solve NPhard problems. However, heuristic or greedy algorithms cannot guarantee the performance. Therefore, in order to design an exact algorithm, we investigated the characteristic of our problem and found that the degrees of many genes were very small (i.e., they were only connected to a small number of TFs in the proteinDNA interaction graph [9, 10]). More specifically, about 70% of genes had degrees less than or equal to 3, about 85% of genes had degrees which are at most 5, and about 96% of genes had degrees less than or equal to 10. This characteristic enabled us to design an efficient exact algorithm, which was presented in Figure 2, for the problem. In addition to its efficiency, our algorithm is the first exact algorithm that can solve a weighted tcover hitting set problem.
Before proving the correctness and time complexity of the algorithm, we give the basic idea of our algorithm, which is based on the dynamical programming technique. When we expand the subsolutions, if two subsolutions H_{1} and H_{2} hit exactly the same group of subsets in \mathcal{T}, we prove that keeping any one of these two subsolutions is sufficient. Hence, if \left\mathcal{T}\right=n, then we keep at most (t + 1)^{n} different subsolutions (Note: there are n subsets, where each subset can be hit by 0, 1, 2, …, or at least t elements in the subsolution. Hence, totally, there are at most (t + 1)^{n} cases.). This is the main part of the time complexity and the space complexity. In the algorithms, we also sort \mathcal{T} such that sizes of subsets in \mathcal{T} are ordered from the smallest to the largest (when there is a tie, an arbitrary order suffices). If sizes of many subsets in \mathcal{T} are bounded, such as sizes of first k subsets {S_{1},S_{2},…,S_{
k
}} are bounded by d, we also sort X such that the first \left{\cup}_{i=1}^{\phantom{\rule{0.3em}{0ex}}j}d{S}_{i}\right elements are {\cup}_{i=1}^{\phantom{\rule{0.3em}{0ex}}j}{S}_{i} for all j = 1, 2, …, k. Hence, the first \left{\cup}_{i=1}^{k}{S}_{i}\right elements are {\cup}_{i=1}^{k}{S}_{i}. In the algorithm, we add the elements of sorted X orderly into the subsolutions (i.e., first, try to add the first element of X into subsolutions. Then try to add the second element of X into subsolutions, and so on.) such that, first, we make S_{1} be hit by at least t elements of each subsolution. Then we make S_{1} and S_{2} be hit by at least t elements of each subsolution, and so on. It is easy to know that when we have considered first \left{\cup}_{i=1}^{k}{S}_{i}\right elements in the sorted X, all {S_{1},S_{2},…,S_{
k
}} are hit by at least t elements of each subsolution. At that time, the number of subsolutions is bounded by {2}^{\left{\cup}_{i=1}^{k}{S}_{i}\right} (all possible combinations of first \left{\cup}_{i=1}^{k}{S}_{i}\right elements in the sorted X). After that, as we only need to remember the hitting statuses of remaining nk subsets in \mathcal{T}, the number of subsolutions is bounded by (t + 1)^{nk}. We will show that if sizes of many subsets in \mathcal{T} are bounded, {2}^{\left{\cup}_{i=1}^{k}{S}_{i}\right} and (t + 1)^{nk} will be much smaller than (t + 1)^{n}.
Let X = {u_{1}, u_{2}, …, u_{
m
}} and \mathcal{T}=\{{S}_{1},{S}_{2},\dots ,{S}_{n}\}. We define {\mathcal{T}}_{X[1:i]}=\left\{S\rightS\in \mathcal{T}\text{and}\phantom{\rule{0.3em}{0ex}}S\subset \{{u}_{1},{u}_{2},\dots ,{u}_{i}\}\} for 1 ≤ i ≤ m. Let H be a subset of X. We define h i t(H) = [c_{1}, c_{2}, …, c_{
n
}], and \mathit{\text{weight}}\left(H\right)=\sum _{u\in H}w\left(u\right), where c_{
i
} = h i t(H)[S_{
i
}] = m i n(t,S_{
i
}∩H) for 1 ≤ i ≤ n, i.e., c_{
i
} remembers how many element(s) in S_{
i
} is(are) in H (Note: if any S_{
i
} already has at least t elements in a partial solution, we can removed S_{
i
} from the problem and do not need to further remember its covering status. Hence, there is no need to remember any S_{
i
}∩H that is large than t). Following lemmas are needed in the proof of the main theorem.
Lemma 0.1
Let H_{1}, H_{2}, H^{′} be three subsets of X such that H_{1} ∩ H^{′} = ∅ and H_{2} ∩ H^{′} = ∅. If h i t(H_{1}) = h i t(H_{2}), then h i t(H_{1} ∪ H^{′}) = h i t(H_{2} ∪ H^{′}).
Proof
As h i t(H_{1}) = h i t(H_{2}), for any {S}_{i}\in \mathcal{T}, h i t(H_{1})[S_{
i
}] = h i t(H_{2})[S_{
i
}], i.e., m i n(t, S_{
i
}∩H_{1}) = m i n(t, S_{
i
} ∩ H_{2}). Furthermore, because H_{1} ∩ H^{′} = ∅ and H_{2} ∩ H^{′} = ∅, we will have that, for any {S}_{i}\in \mathcal{T}, m i n(t, S_{
i
} ∩ (H_{1} ∪ H^{′})) = m i n(t, S_{
i
}∩H_{1} + S_{
i
} ∩ H^{′}) = m i n(t, S_{
i
} ∩ H_{2} + S_{
i
}∩H^{′}) = m i n(t, S_{
i
}∩(H_{2}∪H^{′})). Therefore, h i t(H_{1}∪H^{′}) = h i t(H_{2}∪H^{′}) and the lemma is proved. □
The Lemma 0.1 guarantees that if any two subsolutions cover in the same way, then keeping the subsolution with the smaller weight is enough.
Lemma 0.2
Let {H}^{\ell}=\{{u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{\ell}}\}, whose elements are in the same order as in the sorted X in Algorithm1 (i.e., if j_{1} < j_{2} with respect to the index of H^{ℓ}, then {i}_{{j}_{1}}<{i}_{{j}_{2}} with respect to the index of X), be the minimum tcover hitting set, and {H}_{j}^{\ell}=\{{u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{j}}\}, 1 ≤ j ≤ ℓ. For any 1 ≤ j ≤ ℓ, if there is a H\subset \{{u}_{1},{u}_{2},\dots ,{u}_{{i}_{j}}\} such that \mathit{\text{hit}}\left(H\right)=\mathit{\text{hit}}\left({H}_{j}^{\ell}\right), then \mathit{\text{weight}}\left(H\right)\ge \mathit{\text{weight}}\left({H}_{j}^{\ell}\right).
Proof
Let {H}^{\prime}=\{{u}_{{i}_{j+1}},{u}_{{i}_{j+2}},\dots ,{u}_{{i}_{\ell}}\}. Then H ∩ H^{′} = ∅. If \mathit{\text{weight}}\left(H\right)<\mathit{\text{weight}}\left({H}_{j}^{\ell}\right), then by Lemma 0.1, H ∪ H^{′} will be a tcover hitting set with a smaller weight than the weight of H^{ℓ}, which causes contradiction. Hence, the lemma is correct. □
The Lemma 0.2 shows that Algorithm1 always keeps a subsolution that will lead to the fullsolution with minimum weight. Now, let us present and prove the main theorem.
Theorem 0.3
The weighted tcover hitting set problem can be solved in O((t + 1)^{n}m n t) time and in O((t + 1)^{n}n t) space, where m is the size of the ground set and n is the number of subsets for the given instance. If, furthermore, the problem has at least \frac{n}{1+d/\underset{2}{log}(t+1)} subsets whose sizes are upper bounded by d, then the problem can be solved in O\left({\left({(t+1)}^{d/(d+\underset{2}{log}(t+1\left)\right)}\right)}^{n}\mathit{\text{mnt}}\right) time and in O\left({\left({(t+1)}^{d/(d+\underset{2}{log}(t+1\left)\right)}\right)}^{n}\mathit{\text{nt}}\right) space.
Proof
We first prove the correctness of the algorithm.
Given an instance (X,\mathcal{T},w,t) of the weighted tcover hitting set problem, let X = {u_{1}, u_{2}, …, u_{
m
}}, where X is sorted as shown in Algorithm1 such that the order of elements in X is as S_{1}, S_{2}  X_{1}, …, S_{
n
}X_{n1}, where {X}_{j}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}{\cup}_{i=1}^{\phantom{\rule{0.3em}{0ex}}j}{S}_{i}. Let {H}^{\ell}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}\{{u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{\ell}}\}, whose elements are in the same order as in the sorted X (i.e., if j_{1} < j_{2} with respect to the index of H^{ℓ}, then {i}_{{j}_{1}}\phantom{\rule{0.3em}{0ex}}<\phantom{\rule{0.3em}{0ex}}{i}_{{j}_{2}} with respect to the index of X), be the minimum tcover hitting set. Let {H}_{j}^{\ell}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}\{{u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{j}}\} for all 0 ≤ j ≤ ℓ, where {H}_{0}^{\ell}\phantom{\rule{0.3em}{0ex}}=\phantom{\rule{0.3em}{0ex}}\varnothing.
To prove correctness, we claim that when the for loop in step 2 of Algorithm1 is at loop i = i_{
j
} for all 1 ≤ j ≤ ℓ (Note: {u}_{{i}_{j}} is the j th element in H^{ℓ} and i_{
j
} th element in X), there exists a P = (h i t(H), H) in {\mathcal{Q}}_{\mathit{\text{old}}} (loop in step 3) such that \mathit{\text{hit}}\left(H\right)=\mathit{\text{hit}}\left({H}_{j1}^{\ell}\right) and \mathit{\text{weight}}\left(H\right)=\mathit{\text{weight}}\left({H}_{j1}^{\ell}\right). We prove this claim by mathematical induction on j.

Induction basis. In the case of j = 1, as for any i < i_{1}, {\mathcal{T}}_{X[1:i]}=\varnothing (else, H^{ℓ} cannot be the solution), no subsolution will be removed in step 5.1 for all loops of i < i_{1} in step 2. Hence, when i = i_{1}, P = (h i t(∅), ∅) is in {\mathcal{Q}}_{\mathit{\text{old}}}. The claim is correct.

Induction step. Suppose that when j < q ≤ ℓ, the claim is true. Hence, when i = i_{q1} in the loop of step 2, there exists a P = (h i t(H), H) in {\mathcal{Q}}_{\mathit{\text{old}}} such that \mathit{\text{hit}}\left(H\right)=\mathit{\text{hit}}\left({H}_{q2}^{\ell}\right) and \mathit{\text{weight}}\left(H\right)=\mathit{\text{weight}}\left({H}_{q2}^{\ell}\right). Then by Lemma 0.1, \mathit{\text{hit}}(H\cup \{{u}_{{i}_{q1}}\left\}\right)=\mathit{\text{hit}}({H}_{q2}^{\ell}\cup \{{u}_{{i}_{q1}}\left\}\right)=\mathit{\text{hit}}\left({H}_{q1}^{\ell}\right), and \mathit{\text{weight}}(H\cup \{{u}_{{i}_{q1}}\left\}\right)=\mathit{\text{weight}}\left({H}_{q1}^{\ell}\right). Therefore, {P}^{\ell}=\left(\mathit{\text{hit}}\right({H}_{q1}^{\ell}),{H}_{q1}^{\ell}) will be saved into {\mathcal{Q}}_{\mathit{\text{new}}} unless there is another P^{′} = (h i t(H^{′}), H^{′}) in {\mathcal{Q}}_{\mathit{\text{new}}} such that \mathit{\text{hit}}\left({H}^{\prime}\right)=\mathit{\text{hit}}\left({H}_{q1}^{\ell}\right), and \mathit{\text{weight}}\left({H}^{\prime}\right)=\mathit{\text{weight}}\left({H}_{q1}^{\ell}\right). By Lemma 0.2, if any P^{′} = (h t i(H^{′}), H^{′}) such that \mathit{\text{hit}}\left({H}^{\prime}\right)=\mathit{\text{hit}}\left({H}_{q1}^{\ell}\right), and \mathit{\text{weight}}\left({H}^{\prime}\right)=\mathit{\text{weight}}\left({H}_{q1}^{\ell}\right) is already saved into {\mathcal{Q}}_{\mathit{\text{new}}}, it will not be replaced. Furthermore, as any S\in {\mathcal{T}}_{X[1:i]} for i < i_{
q
}, h i t(H^{′})[S] = t (otherwise, it would cause a contradiction that H^{ℓ} is a solution as no element in \{{u}_{{i}_{q}},\dots ,{u}_{{i}_{\ell}}\} will cover S). Hence, P^{′} = (h i t(H^{′}), H^{′}) will not be removed when loop i < i_{
q
} in loop 2. Thus, P^{′} = (h i t(H^{′}), H^{′}) will be in {\mathcal{Q}}_{\mathit{\text{old}}} when i=i_{
q
} in the loop of step 2, i.e., the claim is still true when j = q.
Therefore, when j = ℓ, we will save a (h i t(H), H) into {\mathcal{Q}}_{\mathit{\text{new}}} such that \mathit{\text{hit}}\left(H\right)=\mathit{\text{hit}}\left({H}_{\ell}^{\ell}\right)=\mathit{\text{hit}}\left({H}^{\ell}\right), and w e i g h t(H) = w e i g h t(H^{ℓ}), i.e., we will find the minimum tcover hitting set. The correctness of Algorithm1 is proved.
Next, we consider the time complexity and space complexity of the algorithm. Step 2 loops X = m times. Step 3 loops \left{\mathcal{Q}}_{\mathit{\text{old}}}\right times. As {\mathcal{Q}}_{\mathit{\text{old}}} only remember different combinations of [c_{1}, c_{3}, …, c_{
n
}] and each c_{
i
} is between 0 and t, it is obvious that \left{\mathcal{Q}}_{\mathit{\text{old}}}\right\le {(t+1)}^{n}. Steps 4.1 to 4.4 take O(n t) time. Steps 4.6 to 4.11 can be finished in O(log2(t + 1)^{n}) = O(n log2(t + 1)) time if we use AVL tree to implement {\mathcal{Q}}_{\mathit{\text{new}}} and {\mathcal{Q}}_{\mathit{\text{old}}}. Hence the total time complexity is O((t + 1)^{n}m n t).
In the case that \mathcal{T} has at least \frac{n}{1+d/\underset{2}{log}(t+1)} subsets whose sizes are bounded from above by d, then when i=\frac{\mathit{\text{dn}}}{1+d/\underset{2}{log}(t+1)}, both {\mathcal{Q}}_{\mathit{\text{old}}} and {\mathcal{Q}}_{\mathit{\text{new}}} have at most {2}^{\frac{\mathit{\text{dn}}}{1+d/\underset{2}{log}(t+1)}}={\left({(t+1)}^{\frac{1}{1+\underset{2}{log}(t+1)/d}}\right)}^{n} elements. Furthermore, when i=\frac{\mathit{\text{dn}}}{1+d/\underset{2}{log}(t+1)}, for any P = (h i t(H), H) in {\mathcal{Q}}_{\mathit{\text{old}}} or in {\mathcal{Q}}_{\mathit{\text{new}}}, if let h i t(H) = [c_{1}, c_{2}, …, c_{
n
}], then c_{
j
} = t for 1\le j\le \frac{n}{1+d/\underset{2}{log}(t+1)}. Hence, when i>\frac{\mathit{\text{dn}}}{1+d/\underset{2}{log}(t+1)}, all elements in {\mathcal{Q}}_{\mathit{\text{old}}} or in {\mathcal{Q}}_{\mathit{\text{new}}} have at most {(t+1)}^{n\frac{n}{1+d/\underset{2}{log}(t+1)}} combinations of h i t(H), i.e., the size of {\mathcal{Q}}_{\mathit{\text{old}}} or {\mathcal{Q}}_{\mathit{\text{new}}} is always bounded from above by {(t+1)}^{n\frac{n}{1+d/\underset{2}{log}(t+1)}}={\left({(t+1)}^{\frac{1}{1+\underset{2}{log}(t+1)/d}}\right)}^{n}. Therefore, the total time complexity is O\left({\left({(t+1)}^{\frac{1}{1+\underset{2}{log}(t+1)/d}}\right)}^{n}\mathit{\text{mnt}}\right).
It is obvious that the space complexity is O\left(\right{\mathcal{Q}}_{\mathit{\text{old}}}\xb7max (lengthes of elements in {\mathcal{Q}}_{\mathit{\text{old}}}\left)\right)=O\left(\right{\mathcal{Q}}_{\mathit{\text{new}}}\left\right)\xb7max (lengthes of elements in {\mathcal{Q}}_{\mathit{\text{new}}}\left)\right). The lengthes of elements in both {\mathcal{Q}}_{\mathit{\text{old}}} and {\mathcal{Q}}_{\mathit{\text{new}}} are bounded from above by O(n t). Therefore, in the general case, the space complexity is O((t + 1)^{n}n t) and in the case sizes of many subsets in \mathcal{T} are bounded from above by d, the space complexity is O\left({\left({(t+1)}^{d/(d+\underset{2}{log}(t+1\left)\right)}\right)}^{n}\mathit{\text{nt}}\right). □
The Algorithn1 only reports one solution with the minimum weight, even problems in application have multiple solutions with the minimum weight. The setting of weights of TFs increases the probability that any solution with the minimum weight includes most correct TFs that regulate differently expressed genes. However, in some cases of the application, we may also want to study other top weight solutions (as the data error, the actual solution may not have the minimum weight). By modifying the algorithm such that for each distinct cover way, save k top weight subsolutions, then the new algorithm can output k top weight solutions. It is also easy to prove that the time complexity and space complexity of the new algorithm will only increase by a ratio k.
Before we finish this section, we briefly summarize the time complexity of our algorithm and compare it with the previously reported one [12]:

If there are at least \frac{n}{1+d/\underset{2}{log}(t+1)} subsets whose sizes are upper bounded by d, then the time complexity of our algorithm is O\left({\left({(t+1)}^{d/(d+\underset{2}{log}(t+1\left)\right)}\right)}^{n}\mathit{\text{mnt}}\right), while the time complexity of the previous best algorithm is always Ω((t + 1)^{n}m n) [12] (and only works for the unweighted case). As d/(d + log2(t + 1)) < 1, {\left({(t+1)}^{d/(d+\underset{2}{log}(t+1\left)\right)}\right)}^{n} is much less than (t+1)^{n}. For example, if we let d = 5 (note: 85% of genes in our case have degrees less than or equal to 5) and t = 2, 3, 4, our algorithm is bounded by O(2.303^{n}m n), O(2.692^{n}m n), or O(3.002^{n}m n) respectively, while the the previous best algorithm is bounded by Ω(3^{n}m n), Ω(4^{n}m n), or Ω(5^{n}m n) respectively. Suppose n = 30, then our algorithm is at least 1393 times faster if t = 2, or 48131 times faster if t = 3, or 1108459 times faster if t = 4 than the previous best algorithm.

The time complexity shown above is only the worst case upper bound; in most cases, the actual time complexity is usually much better. In fact, we can further improve the running time by removing a gene from the graph whenever we find a gene’s degree is less than t. Thus the value of n can be greatly reduced.