递归与循环点滴

recursion : the process of repeating a function, each time applying it to the result of the previous stage.
Word Origin: 1930s: from late Latin recursio(n-), from recurrere ‘run back’, from re- ‘again, back’ + currere ‘run’.

recur
① happen again; happen repeatedly 再发生; 复发
② come back into the mind (想法、事情等)在头脑中重现

loop
① shape produced by a curve crossing itself (曲线自绕所成的)环形, 圈
② any path or pattern shaped roughly like this 环形的轨迹或图案
③ length of string, wire, etc in such a shape, usu fastened at the crossing (绳、金属线等绕成的)环, 结
④ complete circuit for electric current 环形电路
⑤ set of instructions carried out repeatedly until some specified condition is satisfied 循环
⑥ contraceptive coil 避孕环

递归从更高更抽象的角度看问题,比如a[i] = i + 1重复出现。

loop则从指令流的角度看,至少一条jump指令跳到循环开始处。

trie从理论上看简单,具体实现呢?汉字有好几万个,就算看成一串byte,也不能struct [256]吧?要是看成一串bit,那也快不了啊。每层摆一个map或hash map?

以4位为单位,也得[16],2位[4]还行,abcd变成长度16,和65536个元素的二叉树比如何?为啥Linux kernel用红黑树不用trie?

链表得有指针啊。或者破罐子破摔,反正每层用map了,把4个字节看作一个char. 或把所有的看作一个char: 1个map.

这个程序〕用了trie, STL的set和大名鼎鼎的swiss table. 后者慢很多,因为数据量小?

在计算理论中,递归和循环具有等价的计算能力。

不重复的程序就像万字写10000划:a[0]=1; a[1]=2; ...

Common LISP提供了loop宏,可以更直观地实现循环,嘿嘿。

肥波那?切!递归和循环版

跑下题,in Linux的说法是对的; english.stackexchange讨论"running on Windows" vs. "running under Windows".

posted @ 2025-10-28 09:23  华容道专家  阅读(9)  评论(0)    收藏  举报