Decoder inputs needed given 32 registers
Because you need 32 UNIQUE ADDRESS. So if you name your registers 0 to 31 you only need enought bits to represent 31 = b11111.

For the 1 million locations you will need 1million unique addresses. So if you start at zero then the highest address will be 999,999 = 11110100001000111111. So you would need 20bits.