Thanks Aadi,
This is the kind of input that i have
100
0 -33 1 -45 1 -47 1 21 3 -12 4 5 1 1 5 5 4 -36 8 26 4
-4 6 3 7 -8 0 49 1 -38 7 -33 14 18 13 22 1 -44 3 -36 5 -21 14 25 16 -23 17 -5 24 -45 1 5 7 -12 23 -14 11 30 20 -34 25 48 14 36 6 40 4 36
12 37 34 46 35 -12 22 -7 14 45 10 33 17 -37
36 -20 32 -4 29 27 27 -15 0 -39 37 35 7 -49 14 -24 7 -42 7 13 46 -17 27 -31 22 -30 44 -25 5
-7 15 46 40 38 51 -48 48 -23 30 13 12 23 30 -20 6
49 20 -32 31 -26 34 21 47 -30 7 -42 55 -22
25 -43 56 16 35 -50 3 -1 16 -27 0 -8
8 28 54 -10 31 -8 47 46 35 30 23 -24 40 32 46 42
76 23 37 28 1 12 20 43 63 -19 85 24 9 -39 81 -37 76 4 81 -37 12 14 91 44 38 36 29 -43 62 0
The first line contains an integer n, 1 ≤ n ≤ 500000, indicating the number
of nodes, including the entrance node, implicitly labelled 0.
This is then followed by one or more lines, containing n-1 pairs of integers. All integers are separated by single spaces or newlines. The y�th
intersection is defined by the y�th pair of integers 'x p', where 1 ≤ y < n, 0 ≤ x < y, -1000 ≤ p ≤ 1000. & P is the
profit value...
So its kind of weighted graph and then i have to traverse this graph and calculate the max profit...
so for this i tokenize the input.. put it in arraylist and then trying to create a tree from this Arraylist.. and then traverse through that tree to get the results... but im stuck...
So any pointers for this...