返回卡包市场

Recursion

暂无描述。系统推荐的高质量记忆内容,适合每天坚持背诵学习。

卡片总数: 10内容版本: v4公开卡包更新时间: 8/1/2026

卡片预览 (10 张)

#1
正面 (问题)

what is recursion

背面 (解答)

when a function calls itself this produces repetition

#2
正面 (问题)

when is recursion used

背面 (解答)

to make code repeat as an alternative to iteration

#3
正面 (问题)

what are the advantages and limitations of recursion

背面 (解答)

+ shorter and simpler code • each recursion uses up space in memory

#4
正面 (问题)

structure of a recursive function

背面 (解答)

• header w/ name of func and parameters • base case - an if statement, ends as the final return • the name of the function itself with any other parameters

#5
正面 (问题)

the base case

背面 (解答)

an if statement typically at the top of a recursive function defenition if the test is true , the recursion stops

#6
正面 (问题)

how are parameters used in recursuon

背面 (解答)

pass values along the chain of functions that open in memory

#7
正面 (问题)

how to convert a recursive function to iteration

背面 (解答)

• turn the if line of the base case into the header of a while loop, reversing the logic • indent the commands inside the while loop • delete recursive lines

#8
正面 (问题)

how to convert an iterative function to recursion

背面 (解答)

• convert the header of the while loop into a base case (if statement) , reversing the logic add a recursive line at the end of the program consider whether you need to use parameters

#9
正面 (问题)

similarity between recursion and iteration

背面 (解答)

used to repeat blocks of code

#10
正面 (问题)

differences between recursion and iteration

背面 (解答)

recursive function often solves a problem in fewer lines of code, but uses more memory iterative function overrwrites same area of memory repeatedly, using less space iterative functions use more lines to solve the problem