You are not logged in. Please login at to post your questions!


Query relating to TREEDGE

Do we have to go from u to v through their sub-trees or can we go from a parent node?

asked 30 Jan, 22:35

karan26122001's gravatar image

accept rate: 0%

You can go any way. Your aim is to maximise the weighted path length. So choose whichever is greater.

If you consider going through their subtrees, you'll have to add an edge to the end to one of the nodes in their subtree. You can choose this suitable node using dynamic programming.

Here is its editorial.


answered 31 Jan, 08:16

akashbhalotia's gravatar image

accept rate: 10%

edited 27 Feb, 10:12

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 30 Jan, 22:35

question was seen: 104 times

last updated: 27 Feb, 10:12