Aug-26-2021, 04:05 PM
> loop: refers to the repeated execution of the same piece of code when the conditions are met. eg. the
> iterate: refers to visiting each item in the list one by one in a certain order. eg. the
> traversal: refers to visiting each node in the tree structure according to certain rules, and each node is only visited once. Time complexity: O(n)
> recursive: refers to the behavior of a function constantly calling itself. Time complexity: O(2^n)
for example:
while
statement> iterate: refers to visiting each item in the list one by one in a certain order. eg. the
for
statement.> traversal: refers to visiting each node in the tree structure according to certain rules, and each node is only visited once. Time complexity: O(n)
> recursive: refers to the behavior of a function constantly calling itself. Time complexity: O(2^n)
for example:
def Fibonacci(n): if n == 0: return 0; elif n == 1: return 1; return Fibonacci(n-1) + Fibonacci(n-2) # calling function itself