Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What does this code?
#5
> loop: refers to the repeated execution of the same piece of code when the conditions are met. eg. the 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
Reply


Messages In This Thread
What does this code? - by Elvin - May-22-2021, 08:22 PM
RE: What does this code? - by Gribouillis - May-22-2021, 10:39 PM
RE: What does this code? - by Elvin - May-22-2021, 11:35 PM
RE: What does this code? - by Gribouillis - May-23-2021, 06:29 AM
RE: What does this code? - by naughtyCat - Aug-26-2021, 04:05 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020