Example with n=2, m=3, 3 qubits

x is the 2-bit input, b is used to evaluate the function

initial state x=00, b=1, |xb> = |001>

    x  b  amplitudes  (magnitude squared is a probability)
   0 0 0  q[0] = 0
   0 0 1  q[1] = 1
   0 1 0  q[2] = 0
   0 1 1  q[3] = 0
   1 0 0  q[4] = 0
   1 0 1  q[5] = 0
   1 1 0  q[6] = 0
   1 1 1  q[7] = 0

Algorithm:

         H  f  H
  |001>  →  →  →  |yc>
---
if f is always 0, it does nothing:

         H     H
  |001>  →  →  →  |yc>

H is its own inverse, so H * H does nothing overall:

  |001>  →  →  →  |yc>

So if f is always 0, |yc> = |001> and will measure y = 00, c = 1
---
if f is always 1, it flips the state:

         H         f          H
  |001>  →  |++->  →  -|++->  →  -|001> = |yc>

So if f is always 1, |yc> = -|001> and will measure y = 00, c = 1

where:

   |+> = |0> + |1>

   |-> = |0> - |1>

   f(|->) = f(|0> - |1>) = |1> - |0> = - (|0> - |1>) = -|->

(omitting some factors of 1/sqrt(2))
---
Not shown here: if f is balanced, y != 00
---
  x f
  0 0
  1 0
  2 0
  3 0
f is constant
 0 1 0 0 0 0 0 0
 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553
 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553
 0 1 0 0 0 0 0 0
p0 = 1, 1-p0 = -4.44089e-16, f is constant
---
  x f
  0 1
  1 1
  2 1
  3 1
f is constant
 0 1 0 0 0 0 0 0
 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553
 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553
 0 -1 0 0 0 0 0 0
p0 = 1, 1-p0 = -4.44089e-16, f is constant
---
  x f
  0 1
  1 1
  2 0
  3 0
f is balanced
 0 1 0 0 0 0 0 0
 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553 0.353553 -0.353553
 -0.353553 0.353553 -0.353553 0.353553 0.353553 -0.353553 0.353553 -0.353553
 0 0 0 0 0 -1 0 0
p0 = 0, 1-p0 = 1, f is balanced