Internal Path Length: Solving the Mystery

Click For Summary
Internal Path Length (IPL) refers to the total distance from each node in a tree to the root, measured in terms of edges. For a tree with an IPL of 30, this means that if you sum the distances of all nodes from the root, the total will equal 30. The calculation involves labeling each node with its distance from the root and summing these values across all levels of the tree. The IPL does not correlate directly with the number of nodes; rather, it reflects the cumulative distances traversed from the root to each node. Understanding IPL is crucial for analyzing tree structures in data organization and retrieval.
zak100
Messages
462
Reaction score
11

Homework Statement



I can't understand the concept of internal path length. I can't understand what this value mean in the tree? For instance if a IPL of a tree is 30 then what does it mean for the tree. Tree does not have 30 nodes so what the path length means?

Li is the number of nodes in Level i

Homework Equations


Summation (i-1) * Li

The Attempt at a Solution


IPL = 30: for the attached figure(one node at level 0, two at level 1, four at level 2, four at level 3and 2 at level 4:

1 * 0+2* 1 + 4 * 2+ 4 * 3 + 2 * 4= 30.

Some body please tell me how can we see this value in the tree through nodes??

Zulfi
 

Attachments

  • IPL3.jpg
    IPL3.jpg
    12.6 KB · Views: 460
Physics news on Phys.org
The IPL is the sum, over all nodes in the tree, of the distance from each node to the root.

You can see this in a diagram by erasing the numbers written on the nodes of your tree and replacing them by the distance of the node from the root. So the root has 0, the two on the next level have 1, the four on the next level have 2, and so on. Then just add up all the numbers to get the IPL.

It's straightforward to show that that gives the same number as the formula you have written above under 'relevant equations'.

You can also think of it as follows: label the nodes of the tree as 1 to n. Then label n little robots with the numbers from 1 to n and program each robot to walk along the tree to the node with the same label as it has and stop there. Then the IPL is the total distance walked by all the little robots.
 
Hi,
Thanks for your reply. I am calculating the IPL for the tree which i have attached. IPL = 30 & there are only 13 nodes in the tree. This is discrepancy according to what you are saying
<
You can see this in a diagram by erasing the numbers written on the nodes of your tree and replacing them by the distance of the node from the root. So the root has 0, the two on the next level have 1, the four on the next level have 2, and so on. Then just add up all the numbers to get the IPL.>
If possible please show me what you are saying.

Zulfi.
 
zak100 said:
This is discrepancy according to what you are saying
I'm afraid I don't know what you mean by that. To what discrepancy are you referring? I cannot see a discrepancy.
 
Hi,
In my figure which shows a binary tree, it has only 13 nodes, but IPL is 30 (i have shown this in reply #1). According to your words, if i do labeling then root which is at level 1, it should have path length =0 which is correct but level 2, IPL is 2, and then at Level 3 IPL is 10. I mean this is a contradiction with what you are saying. Kindly guide me.

Zulfi.
 
It's not a contradiction. There are five levels. You have only done three. Why would you expect to get the IPL for the whole tree if you only include the first three levels?

Keep going until you have covered all levels and you'll get 30.
 
Hi,
I have already evaluated this 30 value in my reply#1. You say that it represents a distance.
<You can see this in a diagram by erasing the numbers written on the nodes of your tree and replacing them by the distance of the node from the root. >

Tell me what distance 30 is representing? We don't have 30 nodes. We have only 13 nodes. This means that the distance is not in terms of nodes. Also if i add up edges with nodes, i won't get 30. So 30 is not the sum of edges & nodes. So then what does this distance of 30 mean. If i say that IPL is 30 what this value would mean?

Zulfi.
 
zak100 said:
If i say that IPL is 30 what this value would mean?
I have already given you two meanings for it: one in the first paragraph of post 2 and the other in the last paragraph of post 2.

If you cannot understand those explanations then I am afraid there is nothing more that I can do to help you.
 
OK, let's start over.
We will do just the left side of the tree here.

Node 8 is the Root.
Node 3 is next. Node 3's distance from Root is 1, so node 3 is labelled '1'
Node 1 distance from Root is 2 so node 1 is labelled '2'. (Node 3 is already labelled and it has not moved, so leave it alone. It is already labelled.)
Node 5 distance from Root is 2 so node 5 is also labelled '2'. (Node 3 is already labelled, so leave it alone.)
Node 6 distance from Root is 3 so node 6 is labelled '3'. (Nodes 3 & 5 are already labelled, so leave them alone.)
Node 7 distance from Root is 4 so node 7 is labelled '4'. (Nodes 3, 5, 6 are already labelled, so leave them alone.)

Do you see a pattern?
The left side of the tree has an IPL of 1+2+2+3+4 = 12.

Now try the same approach with the right side of the tree.
 
  • #10
Hi my friend,
Great! I like it.
<
Node 8 is the Root.
Node 3 is next. Node 3's distance from Root is 1, so node 3 is labelled '1'
>
You are trying to provide solution to what andrewkirk stated. Good.

I would try what you say but i think i did not make my question clear. You people are talking about distance. Here in case of IPL distance is not in terms of metres or km but i think its in the context of levels and not in terms of nodes, is this correct??

Zulfi.
 
  • #11
Yes. (Mostly)

Or put another way, you could consider each edge to be one unit of distance.
 
  • #12
Hi,
Thanks for your help. The right side of the tree has IPL = 1 + 2 + 2 + 3 + 3+ 3 + 4= 18.
If i sum (IPL of boh sides) them i would get an answer of 30. Can we say that the lowest IPL of tree is 0 & maximum IPL is 30??
Zulfi.
 
  • #13
You could describe the IPL as the total distance (number of edges) traversed if you visited each node in turn, always starting at the root.

For instance if you start in Paris (the root) and travel to Bonn, that's length 1. Then you return to Paris (free, there was a sale on roundtrip tickets). Then the following month you travel to Tokyo from Paris, but you have to change airlines in Bonn. That makes the Tokyo trip length 2. So altogether your travel length was 3; which is the IDL for your vacation. :smile:

The only way to have a zero IDL is if the only node in a tree is the root. You can't have a length if there is no place to go. And if there is a place to go, there is a length.
 
  • #14
Hi,
Thanks for your help.
<You could describe the IPL as the total distance (number of edges) traversed if you visited each node in turn, always starting at the root.>
I feel your above answer is correct.

Zulfi.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K
Replies
15
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 15 ·
Replies
15
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 16 ·
Replies
16
Views
4K