To determine the winner, fourteen ping pong balls numbered 1–14 are placed in a standard lottery machine and four balls are randomly selected from the lot. Just as in most traditional lotteries, the order in which the numbers are drawn is not important. That is, 1-2-3-4 is considered to be the same as 4-3-2-1. So although there is a total of 24 (4!) orders in which the balls numbered 1-2-3-4 can be picked, they are all treated as the same outcome. In doing this, the permutation of 4 balls from 14 becomes the combination of 4 balls from 14. That is, the total of 24,024 (14! / 10!, or 14x13x12x11) possible permutations is reduced by a factor of 24, to 1,001 combinations (or 14! / (10! x 4!)). Of these, 1 outcome is disregarded and 1,000 outcomes are distributed among the 14 non-playoff NBA teams. The combination 11-12-13-14 (in any order that those numbers are drawn) is not assigned and it is ignored if drawn; this has never occurred in practice.
In the event a lottery pick is traded to another team, the record of the original team (whose pick it was before the trade) still determines eligibility for the lottery, and assignment of chances.
...
The lottery is conducted with witnesses verifying that all 14 balls are represented once as they are placed in the lottery machine. The balls are placed in the machine for 20 seconds to randomize prior to having the first ball drawn. The remaining three balls are drawn at 10-second intervals. NBA officials determine which team holds the winning combination and that franchise is awarded the #1 overall draft pick. The four balls are returned to the machine and the process is repeated to determine the second and third picks. In the event that a combination belongs to a team that has already won its pick (or if the one unassigned combination comes up), the round is repeated until a unique winner is determined. When the first three teams have been determined, the remaining picks are given out based on regular season record with the worst teams getting the highest picks. This assures each team that it can drop no more than three spots from its projected draft position.