In how many ways balls be distributed in boxes? There are $5$ different boxes and $7$
 different balls.All the balls are to
 be distributed in the $5$ boxes placed
 in a row so that any box can recieve
 any number of balls.
I am confused on whether the answer should be $5^7$ or $7^5$.
 A: Hint: Suppose there were only 1 ball, and 5 different boxes. How many ways of putting the ball in the boxes would there be then? 
If there were now 2 balls, you can break up your decision about where to put the balls by saying, "First I will decide where Ball 1 goes; then I will decide where Ball 2 goes." Each of these two choices are completely independent - whatever box you choose to put Ball 1 in, it doesn't affect which boxes you might put Ball 2 in. So how many pairs of choices
$$\text{(box for Ball 1, box for Ball 2)}$$
are there?
Can you generalize what is going on to $n$ balls and 5 boxes? In fact it should not be too hard to find the formula for $n$ balls and $k$ boxes.
A: It should be $5^7$ because first ball can go to any of the $5$ boxes and even after that all balls have equal chances to go to all the $5$ boxes. so $5\cdot5\cdot5\cdot5\cdot5\cdot5\cdot5$ ways.
On the othere hand if you think that first box can contain any of the $7$ balls then there is no chance that another box can also receive $7$ balls.
A: The answer will be $5^7$.
Here the balls are different and the boxes are diffrent. Suppose the boxes are $A$, $B$, $C$ and $D$ and the balls are $x$, $y$, $z$. 
x can pair with either A , B , C ,D 
$$ x \times ( A, B, C, D) \tag{1} $$
Likewise,
$$ y \times (A, B, C, D) \tag{2}$$
$$z \times (A, B, C, D) \tag{3}$$
From equation $(1)$ we have 4 choices, and for each choice we have 4 choices from equation $(2)$, and for each choice from equation $(2)$ we have 4 choices from equation $(3)$.
So, $4 \times 4 \times 4 = 4^3$.
Sometime we may think as follows, which is wrong:
In box $A$ we can put $x$, $y$, $z$, therefore 
$$(x, y, z) \times A$$
Similarly,
$$(x ,y ,z) \times B$$
$$(x, y, z) \times C$$
$$(x, y, z) \times D$$
Meaning the total number of choices $= 3 \times 3 \times 3 \times 3$, which is wrong.
Since we have used one ball in $A$, we can not use it for $B$, $C$, or $D$.
A: Hint: You can think of this problem as placing 7 people into 5 rooms. Observe that placing the people is the same as giving each of them a sign (or a key) with the room number, when the people are standing in a prior chosen order.
A: the best of to think is this :
always use fundamental principle of counting when after taking the first decision you can take second decision also independently .
See this .
1. I can place the 1st ball in any of the 5 boxes . Now as far as second ball is concerned it doesn't matter in which box the first ball went , you have 5 ways of putting second ball . Similarly for the following balls .
If you thought otherwise : 
like 1st box can have any of the 7 balls , so for 1st box has 7 choices .
But on putting balls in second box you are not sure how many no of balls went into the first box if all the balls went into the first box then you have only one option that is of choosing no ball at all .
SO IF THIS TYPE OF SITUATION ARISES BE SURE THAT YOU ARE MOVING ON WRONG LOGIC.
A: Are the balls distinguishable? If so, we have 5^7, as each ball has the option of going into any box. If the balls are not distinguishable, then we can use hockey-stick, using four placeable dividers- we have 8C4. 
A: If each box had to have at least $1$ ball, then you put a ball in all the boxes first, then see how many ways you can put $2$ balls in $5$ boxes, which is $5^2$.
