Вы находитесь на странице: 1из 7

ASSIGNMENT2

SUBMISSION DATE
NEXT TUESDAY
EXAMPLE TREE
Representing binary trees in memory

• Binary trees can be represented in memory


either by linked representation or in a
single array using sequential
representation.
Linked representation
Linked representation uses three parallel arrays,
INFO, LEFT and RIGHT and a pointer variable ROOT.
Each node N of T will correspond to a location K
• INFO[K] contains the data at node N
• LEFT[K] contains the location of left child node N
• RIGHT[K] contains the location of right child node N
• ROOT will contain the location of root R of T
Sequential representation
• In sequential representation only one linear
array is used. The root R is stored at TREE [1].
If the node occupies TREE[K], then its left child
is stored at in TREE[K*2] and right child is
stored in TREE[K*2 + 1].

Вам также может понравиться