摘要
在方格矩阵及移动路径的存储方式上优化编程,可以有效地改进"九宫八数"编程的时间复杂度及空间复杂度。采用C语言编程,比较"方阵存储法"与"字串存储法"两种方格矩阵存储方法。实验数据分析可知,"字串存储法"比"方阵存储法"在程序时空效率上更优越。提出建立路径标识矩阵的编程方法,可以有效地简化程序设计代码,提高程序可读性。提出保留路径信息的递归编程方法,可以有效地减少递归压栈空间,显著降低程序空间复杂度,缩短程序运行时间,提高程序效率。
Optimized programming on the storage mode of the grid matrix and mobile path can effectively improve the time complexity and space complexity of the ″ eight-number and nine-grid ″ programming. The paper provides two C language programming and compares the method of ″square matrix storage″ and ″string storage method″. Experimental data analysis shows that the ″ string storage method″ is superior to the ″ square matrix storage method″ in the time-space efficiency of the program. In addition,a programming method is proposed to establish path identification matrix,which can simplify programming code and improve readability. It also proposes a recursive programming method of retaining path information,which can effectively reduce the recursive stack space,significantly reduce program space complexity,reduce program running time,and improve program efficiency.
引文
[1]马旭,王大勇.趣味智能模拟程序设计实例[J].计算机与数字工程,2016,44(5):979-982.
[2]王乐芹,李月,徐炳伟,等.九宫方阵的数学解法[J].数学学习与研究,2015(13):86-86.
[3]惠燕,潘煜.骑士游历问题算法的研究[J].电子设计工程,2011,19(11):112-114.
[4]李彦辉,李爱军.一种改进的广度优先求解华容道问题的方法[J].计算机系统应用,2010,19(11):222-225.
[5]石竑松,秦志光.对数空间可构造的无向图遍历序列[J].计算机工程与应用,2010,46(8):11-15.
[6]欧阳圣,胡望宇.几种经典搜索算法研究与应用[J].计算机系统应用,2011,20(5):243-247.
[7]Kreher D L,Stinson D R.Combinatorial algorithms:generation,enumeration,and search[M].London:CRC Press,1999:151-186.
[8]Jungnickel D.Graphs Networks and Algorithms[M].Translated from German by Tilla Schade Springer,1999:3-51.
[9]单学广,杨庆红,焦莉.递归问题的非递归实现方法的应用研究[J].计算机与现代化,2011(1):25-28.
[10]杨春花,姚进,赵培英,等.一个递归算法非递归化的算法框架[J].计算机应用与软件,2010,27(9):81-84.
[11]雍龙泉.一种全局和声搜索算法求解绝对值方程[J].计算机应用研究,2013,30(11):3276-3279.
[12]高遵海,高颖,程果.图的赋权路径矩阵与所有点对最短路径问题[J].计算机工程与应用,2017,53(9):47-50.
[13]Rohn J.An algorithm for computing all solutions of an absolute value equation[J].Optimization Letters,2012,6(5):851-856.
[14]Zou Dexuan,Gao Liqun,Li Steven,et al.Solving 0-1 knapsack problem by a novel global harmony search algorithm[J].Applied Soft Computing,2011,11(2):1556-1564.
[15]马旭,易俗.二分搜索法求解悬链线问题[J].计算机应用与软件,2017,34(9):50-56.
[16]马旭.超高精度计算程序设计实例[J].计算机工程与应用,2017,53(14):51-55.