type
status
date
slug
summary
tags
category
icon
password
Property
Jul 13, 2023 01:59 PM

Recursion 递归

Video

Review

notion image
notion image
notion image
notion image
example :打印素数的函数

Recursion

notion image
notion image
notion image
递归对于解决具有自然重复结构的问题很有用,它们是根据自身定义的
notion image
比如:DNS 查询
notion image
这也是某种意义上的递归,直到 获取函数的结果

Recursive Function

递归函数
notion image
notion image
notion image
逐渐的将问题缩小,直到缩到最小,缩小到最小,很容得出结果,这样问题就解决了。
notion image
notion image
重在抽象,找到重复的部分
notion image
函数抽象:不要担心阶乘是递归的,只要假设阶乘得到正确的答案

Visualizing Recursion

notion image
notion image
先递到最后一层,再逐渐的归回去
notion image
notion image
notion image
notion image
notion image
 

How To Trust Functional Abstraction

notion image
基准的验证,并且,更大规模的计算是基于基础验证的
notion image

Identifying Patterns

notion image
这个例子中,递归并不是一个hof,因为返回的不是函数,而是函数的调用结果

Example

notion image
notion image
notion image
notion image
这种形式也是可以的,base case不是那么的具体,明显

Sum Digits

notion image
notion image
notion image
可以利用整除和区域来做
notion image
 
notion image

Summary

notion image
 
CS 61A(Part 7) - Recursion ExampleCS 61A(Part 5) - Higher Order Function
  • Waline
Kitety
Kitety
独特为佳
公告
我曾经七次鄙视自己的灵魂
--卡里·纪伯伦
第一次,当它本可进取时,却故作谦卑;
第二次,当它在空虚时,用爱欲来填充;
第三次,在困难和容易之间,它选择了容易;
第四次,它犯了错,却借由别人也会犯错来宽慰自己;
第五次,它自由软弱,却把它认为是生命的坚韧;
第六次,当它鄙夷一张丑恶的嘴脸时,却不知那正是自己面具中的一副;
第七次,它侧身于生活的污泥中,虽不甘心,却又畏首畏尾。
 
最新评论
Loading...