Every time we encounter a single node we find ourselves in the unfortunate situation of having to do two pieces of work: handle its left side and handle its right side. These, in turn, may produce their own work. The stack allows us to solve these problems one step at a time by deferring the branches we do not immediately explore. The stack variable in the iterative solution serves the same purpose as JavaScript’s built-in call stack in the recursive solution.1 We were able to alter the performance characteristics of our code by taking something that the language runtime normally gives us for free, and instead accepting the incidental complexity of managing it manually.
Александра Качан (Редактор)
,详情可参考新收录的资料
Opens in a new window
宇树科技王兴兴:希望未来实现「机器人生产机器人」
走进人民大会堂西藏厅,巨幅壁画《扎西德勒图》颇为壮观。在西藏代表团开放日现场,代表们讨论热烈,暖意融融。