10.3 Implementing pointers and objects and 10.4 Representing rooted trees

Algorithms 

 

10.3 Implementing pointers and  objects  and 10.4 Representing rooted trees 

 

Allocating and freeing objects 

分配和释放对象

it is useful to manage the storage of objects not currently used in the linked -list representation so that one can be allocated  . 

In some systems, a garbage collec- tor is responsible for determining which objects are unused.

一些系统中,垃圾回收机制负责决定哪个对象没有被用到。

 

we keep the free objects in a singly linked list ,which we call the free list .

 

Note that each object in the representation is either in list L or in the  free list ,but not in both .10.3 Implementing pointers and objects and 10.4 Representing rooted trees_第1张图片

10.3 Implementing pointers and objects and 10.4 Representing rooted trees_第2张图片

The free list initially contains all n unallocated objects . Once the free list has been exhausted ,running the allocate-object procedure signals an error .

 

 

 

 

 

10.4 Representing rooted trees 

 

homogeneous  同类的

 we first look at binary trees ,and then we present a method for rooted trees in which nodes can have an arbitrary number of children .

二分树,根数:有任意数量的孩子

 

Binary trees 

 

Rooted trees with unbounded branching 

1. x.left-child points to the leftmost child of node x , and 

2. x.right-sibling points to  the sibling of x immediately to its right .

 

10.3 Implementing pointers and objects and 10.4 Representing rooted trees_第3张图片

你可能感兴趣的:(object)