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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:44:29+00:00 2026-06-01T06:44:29+00:00

Giving a tree that content no cycles (eg a minimum spanning tree : http://fr.wikipedia.org/wiki/Fichier:Minimum_spanning_tree.svg

  • 0

Giving a tree that content no cycles (eg a minimum spanning tree : http://fr.wikipedia.org/wiki/Fichier:Minimum_spanning_tree.svg)
How to calculate which node minimize the tree depth if it is used as root ?

  • 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-06-01T06:44:30+00:00Added an answer on June 1, 2026 at 6:44 am

    All trees contain no cycles. By definition, a tree is an cycle-free, connected graph. If there is one vertex, the answer is trivial. So assume there are at least two vertices.

    Let u and v be two vertices such that their distance d (u, v) is maximum. It should be easy to see that if one selects a vertex along a shortest uv path to be the root, the depth will be at least ceiling (d (u, v) / 2). It should also be noted that if one selects a vertex to be the root not on that path, the depth will be greater than ceiling (d (u, v) / 2).

    Suppose that we have chosen the root r to be the middle vertex along a minimum uv path such that d (u, r) = ceiling (d (u, v) / 2) and d (r, v) ≤ ceiling (d (u, v) / 2). If there were another vertex, w, such that d (r, w) > ceiling (d (u, v) / 2), we would have d (u, r) < d (w, r) and then, because there is only one path between any two distinct vertices in a tree, we have d (u, v) = d (u, r) + d (r, v) < d (u, r) + d (r, w) = d (u, w), which contradicts that u and v have the greatest distance. So now the depth, given r as the root, is ceiling (d (u, v) / 2).

    So we need to find the two vertices with the largest distance. Once we do that, we can use a shortest path-finding algorithm for uv, note the length, and traverse half-way along said path and use that middle vertex as the root.

    How do we find those vertices? Pick a vertex w and place it in a queue. While the queue is non-empty add the neighbors of the next vertex in the queue to the end of the queue. When the queue is empty, take note of the most recently removed vertex. This will be u. Perform the procedure again and you will have v.

    Why does this work? The above algorithm finds a furthest away vertex from w. If w happens to be u or v, the algorithm clearly finds v or u, respectively. So suppose w is neither u nor v. If the algorithm found a u or v in the first pass, again, it will work (for it will find the other in the second pass), so assume, by way of contradiction, that after the first pass it found x such that it is not the end of a maximum path for the tree. From the triangle inequality we have d (u, v) ≤ d (u, w) + d (w, v) and d (v, x) ≤ d (v, w) + d (w, x). Subtracting the second from the first we have d (u, v) – d (v, x) ≤ d (u, w) – d (w, x). We can then rearrange that to d (u, v) + d (w, x) ≤ d (u, w) + d (v, x). Since d (w, u) ≤ d (w, x) (x is the end of a maximum path from w; wu cannot exceed wx) and d (v, x) < d (u, v) (x is not the end of a maximum path), we can strengthen the inequality to d (u, v) + d (w, x) < d (u, v) + d (w, x). That’s not possible, though, so x must be at the end of a maximum path.

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

Sidebar

Related Questions

i have a text-box in my tree that is generated run-time for giving the
Gradle is giving me fits. I have a build.gravle that includes the java plug-in
I'm writing some XML with element tree. I'm giving the code an empty template
I've narrowed the problem down in this post Richfaces tree is giving me an
The code below is giving the following error: An expression tree may not contain
The Problem I need to write a simple software that, giving certain constraints, appends
Giving two variables with the followind values: date1 = Mon Feb 27 16:21:34 WET
Internet Explorer is giving me a serious headache... What I want to do is
My webapplication is giving XML in following format: <Vendor name=Infosys Limited adopTotal=120 totalstrength=775 FY10Q1=162
Google Webmaster Tools is giving me loads of crawl Errors of a certain type

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.