C/C++ Beginner's Guide and Post Basic Questions here

Discussion in 'Programming' started by Liverpool_fan, Oct 14, 2010.

  1. Nerevarine

    Nerevarine Well-Known Member

    Joined:
    Feb 6, 2011
    Messages:
    5,832
    Likes Received:
    128
    Trophy Points:
    63
    Location:
    Pune
    Index n = root
    Index 2n+1 = left child
    Index 2n+2 = right child
    If im not mistaken.
     
  2. quicky008

    quicky008 Well-Known Member

    Joined:
    Nov 27, 2007
    Messages:
    1,370
    Likes Received:
    28
    Trophy Points:
    48
    Location:
    Kolkata
    i remember reading somewhere that in an array representation of a tree,

    if node: i

    Child: 2*i, 2*i+1

    Parent: i/2

    Is this a correct way to represent the array elements as nodes of a binary tree?
     

Share This Page