“Necessary” Uses of Recursion in Imperative Languages

后端 未结 9 1058
独厮守ぢ
独厮守ぢ 2020-12-17 17:10

I\'ve recently seen in a couple of different places comments along the lines of, \"I learned about recursion in school, but have never used it or felt the need for it since

9条回答
  •  一生所求
    2020-12-17 17:50

    When you are walking any kind of tree structure, for example

    • parsing a grammar using a recursive-descent parser
    • walking a DOM tree (e.g. parsed HTML or XML)

    also, every toString() method that calls the toString() of the object members can be considered recursive, too. All object serializing algorithms are recursive.

提交回复
热议问题