Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7492749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:32:40+00:00 2026-05-29T16:32:40+00:00

Hope someone can help, I’m not a programmer, but have been interested in exploring

  • 0

Hope someone can help, I’m not a programmer, but have been interested in exploring Fibonacci sequence and it’s recursive tree…

I’ve created a Binary Tree class, along with an associated TreeNode class, and want to generate a binary tree of the recursive calls created by:

f(n) = f(n-1) + f(n-2) for a given value of n

I’d want to add it as an InsertFibonacci method of my Binary Tree class, replacing the standard Insert method:

def insertNode(self, root, inputData):
    if root == None:
        return self.addNode(inputData)
    else:
        if inputData <= root.nodeData:
            root.left = self.insertNode(root.left, inputData)
        else:
            root.right = self.insertNode(root.right, inputData)
        return root

Would I add somekind of decorator to the Fib function?

# Fib function
def f(n):

    def helper(n):
        left = f(n-1)
        right = f(n-2)
        return left,right

    if n == 0:
        return 0
    elif n == 1:
        return 1
    else:
        left, right = helper(n)
        return left + right
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T16:32:43+00:00Added an answer on May 29, 2026 at 4:32 pm

    Here’s the simplest solution I can think of:

    class FibTree(object):
        def __init__(self, n):
            self.n = n
            if n < 2:
                self.value = n
            else:
                self.left = FibTree(n - 1)
                self.right = FibTree(n - 2)
                self.value = self.left.value + self.right.value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hope someone can help... This issue has been discussed here and I have
hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
Hope someone can help me with this.. I have a magento store up&running, via
I hope someone can help me out. I have a table that logs our
I hope someone can help me. My Problem: I have 2 sortable UL's. <ul
Hope someone can help. I have a simple scenario where clicking checkboxes is driving
I really hope someone can help on this because I'm learning cocoa and have
Hope someone can help with this. I've been up and down the web and
I hope someone can help, I have made a script that masks images... however
I hope someone can help with this. I have created a map app that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.