We implemented the refined Deutsch-Jozsa algorithm on a three-bit nuclear magnetic resonance quantum computer. All of the balanced and constant functions were realized exactly. The results agree well with theoretical predictions and clearly distinguish the balanced functions from constant functions. Efficient refocusing schemes were proposed for the soft z pulse and J coupling, and it is shown that the thermal equilibrium state gives the same answer as the pure state for this algorithm.