Minimum transactions to settle debts among friends
$begingroup$
You are given $n$ integers $x_1,x_2,dots,x_n$ satisfying $sum_{i=1}^n x_i=0$. A legal move is to choose an integer $a$ and two indices $i,j$, and to increase $x_i$ by $a$ and decrease $x_j$ by $a$. The goal is to have $x_1=x_2=dots=x_n=0$.
What is an algorithm which achieves this goal in the fewest number of moves?
There is an algorithm which always takes $n-1$ moves; at the $i^{th}$ step, decrease $x_i$ by $x_i$ and increase $x_{i+1}$ by $x_i$. This is not always optimal, because if half of the $x_i$ equal $1$ and the other half equal $-1$, then $n/2$ moves suffice.
The motivation for this problem is the situation where $n$ friends have gone out to dinner, and have all contributed some amount of money bill, and now want to make it so they have all payed an equal amount.
combinatorics graph-theory algorithms computational-complexity np-complete
$endgroup$
add a comment |
$begingroup$
You are given $n$ integers $x_1,x_2,dots,x_n$ satisfying $sum_{i=1}^n x_i=0$. A legal move is to choose an integer $a$ and two indices $i,j$, and to increase $x_i$ by $a$ and decrease $x_j$ by $a$. The goal is to have $x_1=x_2=dots=x_n=0$.
What is an algorithm which achieves this goal in the fewest number of moves?
There is an algorithm which always takes $n-1$ moves; at the $i^{th}$ step, decrease $x_i$ by $x_i$ and increase $x_{i+1}$ by $x_i$. This is not always optimal, because if half of the $x_i$ equal $1$ and the other half equal $-1$, then $n/2$ moves suffice.
The motivation for this problem is the situation where $n$ friends have gone out to dinner, and have all contributed some amount of money bill, and now want to make it so they have all payed an equal amount.
combinatorics graph-theory algorithms computational-complexity np-complete
$endgroup$
1
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36
add a comment |
$begingroup$
You are given $n$ integers $x_1,x_2,dots,x_n$ satisfying $sum_{i=1}^n x_i=0$. A legal move is to choose an integer $a$ and two indices $i,j$, and to increase $x_i$ by $a$ and decrease $x_j$ by $a$. The goal is to have $x_1=x_2=dots=x_n=0$.
What is an algorithm which achieves this goal in the fewest number of moves?
There is an algorithm which always takes $n-1$ moves; at the $i^{th}$ step, decrease $x_i$ by $x_i$ and increase $x_{i+1}$ by $x_i$. This is not always optimal, because if half of the $x_i$ equal $1$ and the other half equal $-1$, then $n/2$ moves suffice.
The motivation for this problem is the situation where $n$ friends have gone out to dinner, and have all contributed some amount of money bill, and now want to make it so they have all payed an equal amount.
combinatorics graph-theory algorithms computational-complexity np-complete
$endgroup$
You are given $n$ integers $x_1,x_2,dots,x_n$ satisfying $sum_{i=1}^n x_i=0$. A legal move is to choose an integer $a$ and two indices $i,j$, and to increase $x_i$ by $a$ and decrease $x_j$ by $a$. The goal is to have $x_1=x_2=dots=x_n=0$.
What is an algorithm which achieves this goal in the fewest number of moves?
There is an algorithm which always takes $n-1$ moves; at the $i^{th}$ step, decrease $x_i$ by $x_i$ and increase $x_{i+1}$ by $x_i$. This is not always optimal, because if half of the $x_i$ equal $1$ and the other half equal $-1$, then $n/2$ moves suffice.
The motivation for this problem is the situation where $n$ friends have gone out to dinner, and have all contributed some amount of money bill, and now want to make it so they have all payed an equal amount.
combinatorics graph-theory algorithms computational-complexity np-complete
combinatorics graph-theory algorithms computational-complexity np-complete
edited Dec 20 '18 at 3:29
Alex Ravsky
40.2k32282
40.2k32282
asked Dec 19 '18 at 7:44
Sidi ChangSidi Chang
383
383
1
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36
add a comment |
1
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36
1
1
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
Suppose we have some minimum size set of payments, then I claim the resulting (undirected!) payment graph is always a tree. Indeed, suppose the graph has a cycle, then we can adjust all the payments on this cycle by $pm 1$ until one of the edges becomes a payment of $0$ and disappears. We can use this procedure to find an optimal way to resolve any $S subseteq [n]$ with $sum_{iin S} x_i = 0$ using $|S|-1$ payments.
Clearly then, an optimal solution will partition $[n]$ into subsets $S_1,dots,S_k$ such that $sum_{iin S_j} x_i = 0$ for all $1leq j leq k$ and resolve each subset using $|S_j|-1$ payments. In other words, the optimal solution has value $n - k$ where $[n] = S_1 cup dots cup S_k$ is the largest decomposition into subsets summing to $0$.
However, note that if $S_1$ and $S_2$ sum to $0$, then so does $S_1 cup S_2$, so equivalently we may find a maximum length chain $emptyset neq S_1 subseteq dots subseteq S_k = [n]$ and resolve all sets $S_{i+1} setminus S_i$ individuall using $|S_{i+1} setminus S_i|-1$ payments. We can find such a maximum length chain in $O(n2^n)$ time by precomputing for every subset $S subseteq [n]$ the value $s(S) = sum_{iin S} x_i$ and then just using the recurrence:
$$b(S) = begin{cases}
0 & text{if $S = emptyset$} \
1 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) = 0$} \
0 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) neq 0$} \
end{cases}
$$
This is again $O(n2^n)$ time. As was pointed out in the other answer we are unlikely to find a polynomial time algorithm.
$endgroup$
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
add a comment |
$begingroup$
Unfortunately, in this unbalanced world is hard to achieve equality even among friends. Namely, for this problem exists no polynomial algorithm unless $mathcal{ P=NP}$, see below.
Put $[n]= {1,dots, n}.$
Propositon. The goal can be achieved in less then $n-1$ moves iff there is a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$.
Proof. ($Leftarrow$) If there exists such a set $S$ then we can annulate all $x_i$ with $iin S$ by $|S|-1$ moves, and all $x_i$ with $iin [n]setminus S$ by $|[n]setminus S |-1$ moves. Thus we can achieve the goal in at most $|S|-1+|[n]setminus S |-1=n-2$ moves in total.
($Rightarrow$) Assume that the friends can annulate all $x_i$ using $k<n-1$ moves. Consider a graph $G$ with the set $[n]$ of vertices such that the vertices $i$ and $j$ are adjacent by an edge of weight $a$ iff there was a pay of $a$ between $i$-th and $j$-th friend. Since the graph $G$ has less than $n-1$ edges, it has at least two connected components. Clearly, $sum_{iin S} x_i=0$ for each component $S$. $square$
At last we remark that it is NP-hard to decide whether there exists a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$, because this problem is equivalent to Subset sum problem, which is NP-hard. Indeed, given integers $x_1,dots, x_{n-1}$ and $x_n=-sum_{iin [n-1]} x_i$, there exists a subset $S$ of $[n-1]$ such that $sum_{iin S} x_i=0$ iff there exists a proper subset $S’$ of $[n]$ such that $sum_{iin S’} x_i=0$.
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3046139%2fminimum-transactions-to-settle-debts-among-friends%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Suppose we have some minimum size set of payments, then I claim the resulting (undirected!) payment graph is always a tree. Indeed, suppose the graph has a cycle, then we can adjust all the payments on this cycle by $pm 1$ until one of the edges becomes a payment of $0$ and disappears. We can use this procedure to find an optimal way to resolve any $S subseteq [n]$ with $sum_{iin S} x_i = 0$ using $|S|-1$ payments.
Clearly then, an optimal solution will partition $[n]$ into subsets $S_1,dots,S_k$ such that $sum_{iin S_j} x_i = 0$ for all $1leq j leq k$ and resolve each subset using $|S_j|-1$ payments. In other words, the optimal solution has value $n - k$ where $[n] = S_1 cup dots cup S_k$ is the largest decomposition into subsets summing to $0$.
However, note that if $S_1$ and $S_2$ sum to $0$, then so does $S_1 cup S_2$, so equivalently we may find a maximum length chain $emptyset neq S_1 subseteq dots subseteq S_k = [n]$ and resolve all sets $S_{i+1} setminus S_i$ individuall using $|S_{i+1} setminus S_i|-1$ payments. We can find such a maximum length chain in $O(n2^n)$ time by precomputing for every subset $S subseteq [n]$ the value $s(S) = sum_{iin S} x_i$ and then just using the recurrence:
$$b(S) = begin{cases}
0 & text{if $S = emptyset$} \
1 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) = 0$} \
0 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) neq 0$} \
end{cases}
$$
This is again $O(n2^n)$ time. As was pointed out in the other answer we are unlikely to find a polynomial time algorithm.
$endgroup$
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
add a comment |
$begingroup$
Suppose we have some minimum size set of payments, then I claim the resulting (undirected!) payment graph is always a tree. Indeed, suppose the graph has a cycle, then we can adjust all the payments on this cycle by $pm 1$ until one of the edges becomes a payment of $0$ and disappears. We can use this procedure to find an optimal way to resolve any $S subseteq [n]$ with $sum_{iin S} x_i = 0$ using $|S|-1$ payments.
Clearly then, an optimal solution will partition $[n]$ into subsets $S_1,dots,S_k$ such that $sum_{iin S_j} x_i = 0$ for all $1leq j leq k$ and resolve each subset using $|S_j|-1$ payments. In other words, the optimal solution has value $n - k$ where $[n] = S_1 cup dots cup S_k$ is the largest decomposition into subsets summing to $0$.
However, note that if $S_1$ and $S_2$ sum to $0$, then so does $S_1 cup S_2$, so equivalently we may find a maximum length chain $emptyset neq S_1 subseteq dots subseteq S_k = [n]$ and resolve all sets $S_{i+1} setminus S_i$ individuall using $|S_{i+1} setminus S_i|-1$ payments. We can find such a maximum length chain in $O(n2^n)$ time by precomputing for every subset $S subseteq [n]$ the value $s(S) = sum_{iin S} x_i$ and then just using the recurrence:
$$b(S) = begin{cases}
0 & text{if $S = emptyset$} \
1 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) = 0$} \
0 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) neq 0$} \
end{cases}
$$
This is again $O(n2^n)$ time. As was pointed out in the other answer we are unlikely to find a polynomial time algorithm.
$endgroup$
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
add a comment |
$begingroup$
Suppose we have some minimum size set of payments, then I claim the resulting (undirected!) payment graph is always a tree. Indeed, suppose the graph has a cycle, then we can adjust all the payments on this cycle by $pm 1$ until one of the edges becomes a payment of $0$ and disappears. We can use this procedure to find an optimal way to resolve any $S subseteq [n]$ with $sum_{iin S} x_i = 0$ using $|S|-1$ payments.
Clearly then, an optimal solution will partition $[n]$ into subsets $S_1,dots,S_k$ such that $sum_{iin S_j} x_i = 0$ for all $1leq j leq k$ and resolve each subset using $|S_j|-1$ payments. In other words, the optimal solution has value $n - k$ where $[n] = S_1 cup dots cup S_k$ is the largest decomposition into subsets summing to $0$.
However, note that if $S_1$ and $S_2$ sum to $0$, then so does $S_1 cup S_2$, so equivalently we may find a maximum length chain $emptyset neq S_1 subseteq dots subseteq S_k = [n]$ and resolve all sets $S_{i+1} setminus S_i$ individuall using $|S_{i+1} setminus S_i|-1$ payments. We can find such a maximum length chain in $O(n2^n)$ time by precomputing for every subset $S subseteq [n]$ the value $s(S) = sum_{iin S} x_i$ and then just using the recurrence:
$$b(S) = begin{cases}
0 & text{if $S = emptyset$} \
1 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) = 0$} \
0 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) neq 0$} \
end{cases}
$$
This is again $O(n2^n)$ time. As was pointed out in the other answer we are unlikely to find a polynomial time algorithm.
$endgroup$
Suppose we have some minimum size set of payments, then I claim the resulting (undirected!) payment graph is always a tree. Indeed, suppose the graph has a cycle, then we can adjust all the payments on this cycle by $pm 1$ until one of the edges becomes a payment of $0$ and disappears. We can use this procedure to find an optimal way to resolve any $S subseteq [n]$ with $sum_{iin S} x_i = 0$ using $|S|-1$ payments.
Clearly then, an optimal solution will partition $[n]$ into subsets $S_1,dots,S_k$ such that $sum_{iin S_j} x_i = 0$ for all $1leq j leq k$ and resolve each subset using $|S_j|-1$ payments. In other words, the optimal solution has value $n - k$ where $[n] = S_1 cup dots cup S_k$ is the largest decomposition into subsets summing to $0$.
However, note that if $S_1$ and $S_2$ sum to $0$, then so does $S_1 cup S_2$, so equivalently we may find a maximum length chain $emptyset neq S_1 subseteq dots subseteq S_k = [n]$ and resolve all sets $S_{i+1} setminus S_i$ individuall using $|S_{i+1} setminus S_i|-1$ payments. We can find such a maximum length chain in $O(n2^n)$ time by precomputing for every subset $S subseteq [n]$ the value $s(S) = sum_{iin S} x_i$ and then just using the recurrence:
$$b(S) = begin{cases}
0 & text{if $S = emptyset$} \
1 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) = 0$} \
0 + max_{uin S} b(Ssetminus{u}) & text{if $s(S) neq 0$} \
end{cases}
$$
This is again $O(n2^n)$ time. As was pointed out in the other answer we are unlikely to find a polynomial time algorithm.
answered Dec 24 '18 at 13:06
Timon KniggeTimon Knigge
36019
36019
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
add a comment |
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
$begingroup$
This answer sounds fantastic!
$endgroup$
– Sidi Chang
Dec 25 '18 at 2:24
add a comment |
$begingroup$
Unfortunately, in this unbalanced world is hard to achieve equality even among friends. Namely, for this problem exists no polynomial algorithm unless $mathcal{ P=NP}$, see below.
Put $[n]= {1,dots, n}.$
Propositon. The goal can be achieved in less then $n-1$ moves iff there is a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$.
Proof. ($Leftarrow$) If there exists such a set $S$ then we can annulate all $x_i$ with $iin S$ by $|S|-1$ moves, and all $x_i$ with $iin [n]setminus S$ by $|[n]setminus S |-1$ moves. Thus we can achieve the goal in at most $|S|-1+|[n]setminus S |-1=n-2$ moves in total.
($Rightarrow$) Assume that the friends can annulate all $x_i$ using $k<n-1$ moves. Consider a graph $G$ with the set $[n]$ of vertices such that the vertices $i$ and $j$ are adjacent by an edge of weight $a$ iff there was a pay of $a$ between $i$-th and $j$-th friend. Since the graph $G$ has less than $n-1$ edges, it has at least two connected components. Clearly, $sum_{iin S} x_i=0$ for each component $S$. $square$
At last we remark that it is NP-hard to decide whether there exists a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$, because this problem is equivalent to Subset sum problem, which is NP-hard. Indeed, given integers $x_1,dots, x_{n-1}$ and $x_n=-sum_{iin [n-1]} x_i$, there exists a subset $S$ of $[n-1]$ such that $sum_{iin S} x_i=0$ iff there exists a proper subset $S’$ of $[n]$ such that $sum_{iin S’} x_i=0$.
$endgroup$
add a comment |
$begingroup$
Unfortunately, in this unbalanced world is hard to achieve equality even among friends. Namely, for this problem exists no polynomial algorithm unless $mathcal{ P=NP}$, see below.
Put $[n]= {1,dots, n}.$
Propositon. The goal can be achieved in less then $n-1$ moves iff there is a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$.
Proof. ($Leftarrow$) If there exists such a set $S$ then we can annulate all $x_i$ with $iin S$ by $|S|-1$ moves, and all $x_i$ with $iin [n]setminus S$ by $|[n]setminus S |-1$ moves. Thus we can achieve the goal in at most $|S|-1+|[n]setminus S |-1=n-2$ moves in total.
($Rightarrow$) Assume that the friends can annulate all $x_i$ using $k<n-1$ moves. Consider a graph $G$ with the set $[n]$ of vertices such that the vertices $i$ and $j$ are adjacent by an edge of weight $a$ iff there was a pay of $a$ between $i$-th and $j$-th friend. Since the graph $G$ has less than $n-1$ edges, it has at least two connected components. Clearly, $sum_{iin S} x_i=0$ for each component $S$. $square$
At last we remark that it is NP-hard to decide whether there exists a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$, because this problem is equivalent to Subset sum problem, which is NP-hard. Indeed, given integers $x_1,dots, x_{n-1}$ and $x_n=-sum_{iin [n-1]} x_i$, there exists a subset $S$ of $[n-1]$ such that $sum_{iin S} x_i=0$ iff there exists a proper subset $S’$ of $[n]$ such that $sum_{iin S’} x_i=0$.
$endgroup$
add a comment |
$begingroup$
Unfortunately, in this unbalanced world is hard to achieve equality even among friends. Namely, for this problem exists no polynomial algorithm unless $mathcal{ P=NP}$, see below.
Put $[n]= {1,dots, n}.$
Propositon. The goal can be achieved in less then $n-1$ moves iff there is a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$.
Proof. ($Leftarrow$) If there exists such a set $S$ then we can annulate all $x_i$ with $iin S$ by $|S|-1$ moves, and all $x_i$ with $iin [n]setminus S$ by $|[n]setminus S |-1$ moves. Thus we can achieve the goal in at most $|S|-1+|[n]setminus S |-1=n-2$ moves in total.
($Rightarrow$) Assume that the friends can annulate all $x_i$ using $k<n-1$ moves. Consider a graph $G$ with the set $[n]$ of vertices such that the vertices $i$ and $j$ are adjacent by an edge of weight $a$ iff there was a pay of $a$ between $i$-th and $j$-th friend. Since the graph $G$ has less than $n-1$ edges, it has at least two connected components. Clearly, $sum_{iin S} x_i=0$ for each component $S$. $square$
At last we remark that it is NP-hard to decide whether there exists a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$, because this problem is equivalent to Subset sum problem, which is NP-hard. Indeed, given integers $x_1,dots, x_{n-1}$ and $x_n=-sum_{iin [n-1]} x_i$, there exists a subset $S$ of $[n-1]$ such that $sum_{iin S} x_i=0$ iff there exists a proper subset $S’$ of $[n]$ such that $sum_{iin S’} x_i=0$.
$endgroup$
Unfortunately, in this unbalanced world is hard to achieve equality even among friends. Namely, for this problem exists no polynomial algorithm unless $mathcal{ P=NP}$, see below.
Put $[n]= {1,dots, n}.$
Propositon. The goal can be achieved in less then $n-1$ moves iff there is a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$.
Proof. ($Leftarrow$) If there exists such a set $S$ then we can annulate all $x_i$ with $iin S$ by $|S|-1$ moves, and all $x_i$ with $iin [n]setminus S$ by $|[n]setminus S |-1$ moves. Thus we can achieve the goal in at most $|S|-1+|[n]setminus S |-1=n-2$ moves in total.
($Rightarrow$) Assume that the friends can annulate all $x_i$ using $k<n-1$ moves. Consider a graph $G$ with the set $[n]$ of vertices such that the vertices $i$ and $j$ are adjacent by an edge of weight $a$ iff there was a pay of $a$ between $i$-th and $j$-th friend. Since the graph $G$ has less than $n-1$ edges, it has at least two connected components. Clearly, $sum_{iin S} x_i=0$ for each component $S$. $square$
At last we remark that it is NP-hard to decide whether there exists a proper subset $S$ of $[n]$ such that $sum_{iin S} x_i=0$, because this problem is equivalent to Subset sum problem, which is NP-hard. Indeed, given integers $x_1,dots, x_{n-1}$ and $x_n=-sum_{iin [n-1]} x_i$, there exists a subset $S$ of $[n-1]$ such that $sum_{iin S} x_i=0$ iff there exists a proper subset $S’$ of $[n]$ such that $sum_{iin S’} x_i=0$.
answered Dec 20 '18 at 3:28
Alex RavskyAlex Ravsky
40.2k32282
40.2k32282
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3046139%2fminimum-transactions-to-settle-debts-among-friends%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
$begingroup$
If you remove all 'friends' from the problem whose balance is already $0$, then the problem is immediately reduced (at a fixed cost of $n$). After this, to your point, you have a lower boundary of ~$k/2$ where $k$ is the remaining number of friends with a non-zero balance.
$endgroup$
– jameselmore
Dec 19 '18 at 19:36