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 1049375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:36:23+00:00 2026-05-16T16:36:23+00:00

This is some code found on wikipedia regarding BST : # ‘node’ refers to

  • 0

This is some code found on wikipedia regarding BST :

# 'node' refers to the parent-node in this case
 def search_binary_tree(node, key):
     if node is None:
         return None  # key not found
     if key < node.key:
         return search_binary_tree(node.leftChild, key)
     elif key > node.key:
         return search_binary_tree(node.rightChild, key)
     else:  # key is equal to node key
         return node.value  # found key

Now here’s a Binary Tree :

       10
    5        12
  3   8    9   14
     4 11  

If I am searching for 11, and I follow the algorithm up there, I start with 10, I go right to 12, and then left to 9. And I reach the end of the tree without finding 11.
But 11 exists in my tree, it’s just on the other side.

Can you please explain what are the restrictions in a Binary Tree for this algorithm to work on my tree ?

Thanks.

  • 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-16T16:36:24+00:00Added an answer on May 16, 2026 at 4:36 pm

    It’s just because your tree is not a binary search tree: it is not ordered correctly. The BST is build as described in the algorithm actually. For instance in your tree: the node ‘9’ is not at the right position because as 9 < 10 it should be under the left branch of your root node ’10’. Same for ’14’ and ’11’ which should be on the right branch.

    for instance a BST could sth like this:

        10
      5    11
    3   8    12
              14
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with some code I found online: def person_path(options) # This is
This is a source code for Quicksort in Python I found on Wikipedia. def
This is some code I found on the internet. I'm not sure how it
I'm trying to parse a html doc using some code I found from this
in some CSS code I found out this type of selector div#someid Is this
Example: We found this is some vendor written code and we're trying to figure
I found this line of code in some code I'm analyzing: Mintau = (double*)
I found some mapkit code on the internet that looks like this: - (void)recenterMap
Watching some code found on internet I came across this piece of code: int
I'm attempting to utilize some code found here: http://androidtabs.googlecode.com/svn/trunk/ This includes the bases classes

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.