华东师范大学学报(自然科学版)Issue(5):32-42,11.DOI:10.3969/j.issn.1000-5641.2025.05.004
基于智能体的可交互数据结构和算法可视化实现
Interactive data structure and algorithm visualization based on AI agents
摘要
Abstract
Data structures and algorithms(DSA),as a core course in computer science education,play a key role in cultivating programming skills and algorithmic thinking of students.Visualization can significantly enhance teaching effectiveness and deepen student understanding in DSA education.However,existing DSA visualization tools often rely on manually written visualization codes that lead to limitations such as limited coverage,high maintenance costs,and lack of interactivity;hence,the needs of dynamic demonstrations and personalized teaching are difficult to meet.With the outstanding performance of large language models(LLMs)in code generation,automated DSA visualization has become a promising possibility.Therefore,this study proposed an interactive visualization code generation method based on the reasoning and acting(ReAct)AI agent framework,aiming to address the low automation and insufficient interactivity of traditional visualization tools.By leveraging the code generation capabilities of LLMs and integrating with the data structure visualization(DSV)platform interface,the proposed method transformed Python-based DSA code into interactive,executable,and dynamically visualized code,thereby enhancing teaching clarity and learning experience.To systematically evaluate the effectiveness of the method,we constructed a dataset of 150 pairs of DSA code and corresponding DSV visualization code and compared three approaches—direct prompting,chain-of-thought prompting,and the ReAct AI agent approach—across several mainstream LLMs.The experimental results showed that the proposed ReAct AI agent-based method significantly outperformed the other approaches in terms of the compilation rate,execution rate,and usability rate,with the best performance observed in the DeepSeek-R1 model.This demonstrated notable improvements in the accuracy and interactivity of generated visualization code.This research confirms the feasibility and advantages of integrating LLMs with agent frameworks in DSA visualization teaching,offering a novel path toward building efficient,personalized,and automated tools for computer programming education.关键词
数据结构与算法可视化/大语言模型/智能体/代码生成Key words
data structure and algorithm visualization/large language model/AI agent/code generation分类
信息技术与安全科学引用本文复制引用
庞瑞洋,陆雪松..基于智能体的可交互数据结构和算法可视化实现[J].华东师范大学学报(自然科学版),2025,(5):32-42,11.基金项目
国家重点研发计划(2023YFC3341200) (2023YFC3341200)
国家自然科学基金(62277017) (62277017)