# Explain how assigning n tasks to n persons randomly gives a sample space of n^n?

I was studying linearity of expectation topic and there was an example of assigning n processes to n different servers randomly, as per i can think - 1st process to any of n servers so "n" ways, 2nd process to any of the n servers, so again "n" ways, in the same way nth process to any of the n servers, again in "n" ways. A total of n times n so n^2 ways(so the sample space), but the actual sample space said was n^n. How can it be? Thanks.

Denote the set of servers as $S = \{s_1,s_2,\dots,s_n\}$.
An outcome of this experiment is a length-$n$ tuple belonging to the set $S^n$ (the set of all possible outcomes, aka sample space). Its cardinality is $|S|^n=n^n$ by the rule of product.
To make this a little clearer, we can express an outcome in the form $(p_1,p_2,\dots,p_n)$ where $p_i$ is the server who has been assigned process $p_i$.