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

  • Home
  • SEARCH
  • 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 6618421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:49:52+00:00 2026-05-25T20:49:52+00:00

I read about binary search trees that if it is a complete tree (all

  • 0

I read about binary search trees that if it is a complete tree (all nodes except leaf nodes have two children) having n nodes, then no path can have more than 1+log n nodes.

Here is the calculation I did… can you show me where did I go wrong….

the first level of bst has only one node(i.e. the root)-->2^0
the second level have 2 nodes(the children of root)---->2^1
the third level has 2^3=8 nodes
 .
 .
the (x+1)th level has 2^x nodes

so the total number of nodes =n = 2^0 +2^1 +2^2 +...+2^x = 2^(x+1)-1
so, x=log(n+1)-1

now as it is a 'complete' tree...the longest path(which has most no of nodes)=x
and so the nodes experienced in this path is x+1= log(n+1)

Then how did the number 1+log n come up…?

  • 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-25T20:49:52+00:00Added an answer on May 25, 2026 at 8:49 pm

    Shorter answer: the number x of levels in a complete (or perfect) binary tree is log2(n+1), where n is the number of nodes (alternatively, n = 2^(x-1)). A tree with x levels has height x-1. The longest path from the root to any node contains x = log2(n+1) nodes (and x-1 edges).

    Now because n+1 is a power of 2, we have that log2(n+1) = 1 + floor(log2(n)). In other words, 1 + log2(n) is a correct upper-bound, but it is never an integer.

    It is unclear to me whether the x in your computation refers to the height or the number of levels.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a binary file (about 100 MB) that I need to read in quickly.
I have a binary file with variable length record that looks about like this:
I've read some Q&As about self-balancing binary trees, but I'm not quite familiar with
Ive read about it and to be honest it all seems like a bunch
I read about an inheritance feature in PostgreSQL that seemed pretty neat. Unfortunately I
I came across an article on Binary Trees Search . It uses intensive Recursive
I've read about binary searches on Wikipedia for the first time today and just
When I have two mysql servers that have different jobs (holding different databases) but
I read the tutorials about the binary and unary functions. I understood the structure
Let's say you have a List<List<Boolean>> and you want to encode that into binary

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.