Tree and Graph Challenges Comments

Comments

  • it was a good challenge figuring out how to do this with the array representation, very satisfied to have solved it

  • Here's some code to set up the tree in Java so you can just do the algorithm.

  • I have a doubt ! In this Output

    Input:
    4
    2 6 9 11
    7 8 9 8
    6 7 12 9
    10 7 6 4

    Output(given as) :
    B A A A
    B B B A
    C B B B
    C C B B

    Can anyone explain the output of this case please?

  • If 11 is the peak element then how come 6,9 and 8 which is marked as A in output is treated
    a areas of peak element. Can anyone could please give me a example ?

  • 9 and 8 can each be reached by going down from 11 so they're part of Area A. Similarly the 6 on top can be reached by going down from the 9, so it also ends up as part of A.

  • Why does the top 6 ends up beaing part of A and not B?

    @Learneroo Could you please explain in detail how the areas are determined in the last example? I can't figure out how the top 2, 7, and 8 are reached by the 12 peak.

    cont...
  • When a cell is surrounded by multiple cells of higher values, it joins the area of the higher valued cell (regardless of who's peak is higher). It might be easier to work from the small cells back to the peaks, instead of from the peaks down.

    cont...
  • pay attention to the fact that the explorer can only move right or down!

Contact Us
Sign in or email us at [email protected]