🤖 AI Summary
To address the challenge of modeling algorithmic execution semantics for code time-complexity prediction under low-resource settings—where scarce labeled samples hinder accurate generalization—this paper proposes the first semi-supervised learning framework tailored to this task. Methodologically, it integrates three key innovations: (1) code symbolic augmentation via static analysis and symbolic execution to enhance semantic representation robustness; (2) an interpretable symbolic module that explicitly models asymptotic behavior; and (3) a multi-view collaborative training mechanism to effectively leverage unlabeled data. Under low-resource conditions (only 10–50 labeled examples), our approach achieves over 60% improvement in accuracy over a self-training baseline, significantly outperforming large language models including ChatGPT and Gemini-Pro. It strikes a superior balance between predictive accuracy and interpretability, offering both quantitative gains and principled insight into algorithmic complexity.
📝 Abstract
Time complexity is a theoretic measure to determine the amount of time the algorithm needs for its execution. In reality, developers write algorithms into code snippets within limited resources, making the calculation of a code's time complexity a fundamental task. However, determining the precise time complexity of a code is theoretically undecidable. In response, recent advancements have leaned toward deploying datasets for code time complexity prediction and initiating preliminary experiments for this challenge. We investigate the challenge in low-resource scenarios where only a few labeled instances are given for training. Remarkably, we are the first to introduce TCProF: a Time-Complexity Prediction SSL Framework as an effective solution for code time complexity prediction in low-resource settings. TCProF significantly boosts performance by integrating our augmentation, symbolic modules, and a co-training mechanism, achieving a more than 60% improvement over self-training approaches. We further provide an extensive comparative analysis between TCProF, ChatGPT, and Gemini-Pro, offering a detailed evaluation of our approach. Our code is at https://github.com/peer0/few-shot-tc.