Stars and Bars Equivalence

Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.
for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement
How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?
This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.
Stars and Bars:
If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.
If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$
combinatorics
add a comment |Â
up vote
1
down vote
favorite
My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.
for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement
How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?
This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.
Stars and Bars:
If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.
If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$
combinatorics
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.
for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement
How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?
This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.
Stars and Bars:
If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.
If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$
combinatorics
My textbook says that "statement" executes $10+(3-1)choose3$ times for the following pseudocode without giving any details on why (I know that $n=10$ and $r=3$). I have verified this to be correct with a simple script.
for i = 1 up to 10
for j = 1 up to i
for k = 1 up to j
statement
How can I visualize how many times "statement" is run through the use of stars and bars or any other combinatorial argument?
This is not the same as this or this - they are only calculating how many times it is run without using stars and bars.
Stars and Bars:
If there are $n$ identical objects and $r$ distinct containers, then there are $n + (r-1)chooser$ possibilities to distribute the objects.
If there are $5$ objects and $3$ containers, then $3$ objects in container 1, $1$ object in container 2 and $1$ object in container 3 can be represented with stars and bars by $***|*|*$
combinatorics
combinatorics
asked Sep 9 at 5:49
hioqobipb
153
153
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04
add a comment |Â
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.
where $a,b,c,d$ each represents the 'stars' in every container:
For example in $(âÂÂâÂÂâÂÂ|âÂÂ|âÂÂâÂÂ|âÂÂâÂÂâÂÂ)$ $a=3, b=1, c=2, d=3$
Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.
Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.
*Your formula for stars and bars is not correct.
Source: Brilliant.org
The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is
$$ binomn+r-1n = binomn+r-1r-1. _square $$
which is not the same as the formula you have given, i.e. $n + (r-1)chooser$
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.
where $a,b,c,d$ each represents the 'stars' in every container:
For example in $(âÂÂâÂÂâÂÂ|âÂÂ|âÂÂâÂÂ|âÂÂâÂÂâÂÂ)$ $a=3, b=1, c=2, d=3$
Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.
Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.
*Your formula for stars and bars is not correct.
Source: Brilliant.org
The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is
$$ binomn+r-1n = binomn+r-1r-1. _square $$
which is not the same as the formula you have given, i.e. $n + (r-1)chooser$
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
add a comment |Â
up vote
2
down vote
accepted
Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.
where $a,b,c,d$ each represents the 'stars' in every container:
For example in $(âÂÂâÂÂâÂÂ|âÂÂ|âÂÂâÂÂ|âÂÂâÂÂâÂÂ)$ $a=3, b=1, c=2, d=3$
Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.
Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.
*Your formula for stars and bars is not correct.
Source: Brilliant.org
The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is
$$ binomn+r-1n = binomn+r-1r-1. _square $$
which is not the same as the formula you have given, i.e. $n + (r-1)chooser$
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.
where $a,b,c,d$ each represents the 'stars' in every container:
For example in $(âÂÂâÂÂâÂÂ|âÂÂ|âÂÂâÂÂ|âÂÂâÂÂâÂÂ)$ $a=3, b=1, c=2, d=3$
Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.
Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.
*Your formula for stars and bars is not correct.
Source: Brilliant.org
The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is
$$ binomn+r-1n = binomn+r-1r-1. _square $$
which is not the same as the formula you have given, i.e. $n + (r-1)chooser$
Let $10 =a+b+c+d+1, i=b+c+d+1, j=c+d+1, k=d+1$.
where $a,b,c,d$ each represents the 'stars' in every container:
For example in $(âÂÂâÂÂâÂÂ|âÂÂ|âÂÂâÂÂ|âÂÂâÂÂâÂÂ)$ $a=3, b=1, c=2, d=3$
Then $mathrmthe number of permutations = 9+(4-1)choose (4-1) = 12choose 3 $which apparently is the same as the given one in the textbook.
Then $i$ will be any number from $1$ to $10$, $j$ will be any number from $1$ to $i$, and $k$ will be any number from $1$ to $j$.
*Your formula for stars and bars is not correct.
Source: Brilliant.org
The number of ways to place $n$ indistinguishable balls into $r$ labelled urns is
$$ binomn+r-1n = binomn+r-1r-1. _square $$
which is not the same as the formula you have given, i.e. $n + (r-1)chooser$
edited Sep 11 at 3:40
answered Sep 9 at 6:30
Vee Hua Zhi
74718
74718
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
add a comment |Â
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
But to use the formula, doesn't $a,b,c,d ge 0$? This doesn't work when $a=10, b=0, c=0, d=0$ ($0 not ge 1$ as required by loop conditions)
â hioqobipb
Sep 9 at 17:13
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
I have edited my solution
â Vee Hua Zhi
Sep 10 at 1:07
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula I gave is correct (from your formula, let $n = r$ and $k = n$). Then we have $binomr+n-1r = binomn+(r-1)r$
â hioqobipb
Sep 10 at 2:06
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
The formula is NOT the same: My $r$ represents labelled urns and my $n$ represents indistinguishable balls, but yours is different. The change between $n$ and $r$ will make a huge difference.
â Vee Hua Zhi
Sep 11 at 3:44
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
You should read more to understand the reason behind stars and bars. brilliant.org/wiki/integer-equations-star-and-bars is a good wiki.
â Vee Hua Zhi
Sep 11 at 3:45
add a comment |Â
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2910444%2fstars-and-bars-equivalence%23new-answer', 'question_page');
);
Post as a guest
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
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
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
Did the textbook give you $10+(3-1)choose3$ or did it give you $12choose 3$ and you changed it yourself?
â Vee Hua Zhi
Sep 10 at 1:08
It gave me $10+3-1choose3$, without "(" and ")"
â hioqobipb
Sep 10 at 2:04