The NEw Distributed Arithmetic (NEDA) completes multiply/accumulate by an adder only and achieves excellent performance in terms of area and power by pairwise matching to reduce the computational redundancy in the coefficient matrix. In this paper, an optimal algorithm for grouping in NEDA is introduced, which is effective in eliminating the redundancy in the coefficient matrix. By finding the matched ports, the proposed algorithm makes an effective hierarchy table with the times of the ports usage. The experimental data shows that the algorithm exploits the NEDA coefficient redundancy of DCT and FFT quickly and effectively, which makes it useful for the hardware design of DSP, insofar it improves the correlative hardware design efficiency.