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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:52:28+00:00 2026-05-29T10:52:28+00:00

Compute the average distance from a node to the root in a worst-case tree

  • 0
Compute the average distance from a node to the root in a worst-case tree of 
2^n nodes built by the weighted quick union algorithm?

This is an exercise in Algorithm in C++(Robert Sedgewick).

I know the worst case distance but can someone suggest me correct way to compute average distance?

Worst case scenario is the merging of 2 tree with same number of nodes. lets say merge 2 tree each having 2^n nodes, resulting tree [=size 2^(n+1) nodes] will have n+1 max distance of any node from the root ( more than 1 after merge).

In worst case- if tree size is 2^n, distance from root to any of the node is always less than n.

How can we calculate the average distance if the max distance is n for 2^n node tree?

  • 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-29T10:52:28+00:00Added an answer on May 29, 2026 at 10:52 am

    The worst case is as you said, you always add two trees of the same height. In order to achieve it, you need: 2 trees of height n-1, and to achieve it you need 4 trees of height n-2, ….

    At the end, you need n trees of height 1, n/2 trees of height 2, …, 1 tree of height n.

    Since this is your homework, I will be done by hinting you how to continue:

    Use the prvious observation, and follow the algorithm to build the trees and “achieve” worst case. Note how many leaves there are in each depth – if you build a tree this way [start with examples of private cases, n=1,2,3 and see how it “behaves”]

    If you need to formally prove it – it should be probably done by induction on the height [n].

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

Sidebar

Related Questions

How do you compute the average height of a binary search tree when adding
Im trying to compute a 24 hour rms (root mean squared) from a dataset
I am trying to compute an average value from a collection using the mongodb
I've a C code which compute the distance between two sets of nodes (three
I'm trying to compute the average of a field over various subsets of a
I have to compute a value involving data from several tables. I was wondering
I'm looking for an algorithm which someone has access to that will compute the
Everything in my code works, its getting input from file, computing average, and outputting.
I can successfully compute the 200 day moving average for one ticker using a
I want to compute the average execution time of x number of runs (i.e.

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.