In Arduino, just setting the pin as input already makes it high impedance.
Writing HIGH on an input pin actually enables its internal pull-up resistor.
This way, the voltage at the pin is always defined (instead of floating when the switch is open).
Just search for "pull-up resistor" if you need more information.
Note that this code:
pinMode(n, INPUT);//set as input, high-impedance
digitalWrite(n, HIGH);//activate the internal pull-up resistor
is equivalent to this (in recent Arduino IDEs):