Sequence alignment is a fundamental topic in bioinformatics research, crucial for analyzing the similarity between gene sequences using specific algorithms. In this study, we propose an enhanced Needleman-Wunsch algorithm that leverages truncated sequences. By truncating the sequences during score matrix calculation and constructing a matching matrix based on common sequence elements, we significantly optimize the efficiency of the original algorithm. Furthermore, we provide a theoretical analysis of the time complexity of the improved Needleman-Wunsch algorithm, along with concrete examples to validate its complexity and accuracy. The resulting improved model demonstrates superior speed and accuracy. Additionally, we enhance traditional distance estimation using the maximum likelihood method, incorporating local optimization techniques. This improvement leads to enhanced quality in the distance matrix and improved accuracy in pedigree tree construction. Lastly, addressing the limitations of the adjacency algorithm, we introduce evolutionary distance variance and covariance, refining the model's accuracy and robustness.