Re: [BLACKBOX] AVL Trees

From: [at]} <Chris>
Date: Mon, 5 Sep 2011 22:33:50 +0930

----boundary-LibPST-iamunique-1489252809_-_-
Content-type: text/plain

>-----Original Message-----
>From: BlackBox [mailto:BLACKBOX{([at]})nowhere.xy
>Campbell, Robert (SELEX GALILEO, UK)
>Sent: Monday, 5 September 2011 6:34 PM
>To: BLACKBOX{([at]})nowhere.xy
>Subject: Re: [BLACKBOX] AVL Trees
>
>Bob
>
>Thanks for the reference (why didn't I look there first?)
>
>In section 4.5.2, in procedure "balanceR", there is an
>assignment "b2 := p2.bal;".
>
>b2 is neither declared or used, and this assigment is not in
>the mirror procedure "balanceR". I guess that it is there by
>error, and should simply be omitted. When I do that the
>procedure seems to work.
>
>Is there another version of the book (Pascal or Modula-II) on
>the web so I can check what they say?
>

Robert,

In the 1982 Modula-2 edition of the book, b2 was a local variable declared
as a subrange type:

  b1, b2: -1..+1;

The initial assignment was equivalent:

  b2 := p2^.bal;

and b2 was then used in the later statements. Instead of:

  IF p2.bal = -1 THEN p.bal := 1 ELSE p.bal := 0 END ;
  IF p2.bal = +1 THEN p1.bal := -1 ELSE p1.bal := 0 END ;

the equivalent statements were:

  IF b2 = -1 THEN p.bal := 1 ELSE p.bal := 0 END ;
  IF b2 = +1 THEN p1.bal := -1 ELSE p1.bal := 0 END ;

b1 was used similarly as a substitute for p1^.bal. As the value of p2 does
not change from the time it is assigned to b2 to the time it is referenced I
believe that you can safely remove the assignment to b2 as you have already
done.

Regards,
Chris

Chris Burrows
CFB Software
http://www.cfbsoftware.com


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1489252809_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZ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EgRUxTRSBw
MS5iYWwgOj0gMCBFTkQgO1xwYXINClxwYXINCmIxIHdhcyB1c2VkIHNpbWlsYXJseSBhcyBhIHN1
YnN0aXR1dGUgZm9yIHAxXi5iYWwuIEFzIHRoZSB2YWx1ZSBvZiBwMiBkb2VzXHBhcg0Kbm90IGNo
YW5nZSBmcm9tIHRoZSB0aW1lIGl0IGlzIGFzc2lnbmVkIHRvIGIyIHRvIHRoZSB0aW1lIGl0IGlz
IHJlZmVyZW5jZWQgSVxwYXINCmJlbGlldmUgdGhhdCB5b3UgY2FuIHNhZmVseSByZW1vdmUgdGhl
IGFzc2lnbm1lbnQgdG8gYjIgYXMgeW91IGhhdmUgYWxyZWFkeVxwYXINCmRvbmUuXHBhcg0KXHBh
cg0KUmVnYXJkcyxccGFyDQpDaHJpc1xwYXINClxwYXINCkNocmlzIEJ1cnJvd3NccGFyDQpDRkIg
U29mdHdhcmVccGFyDQpodHRwOi8vd3d3LmNmYnNvZnR3YXJlLmNvbVxwYXINClxwYXINClxwYXIN
Ci0tLS1ccGFyDQpUbyB1bnN1YnNjcmliZSwgc2VuZCBhIG1lc3NhZ2Ugd2l0aCBib2R5ICJTSUdO
T0ZGIEJMQUNLQk9YIiB0byBMSVNUU0VSVkBMSVNUUy5PQkVST04uQ0hccGFyDQp9
----boundary-LibPST-iamunique-1489252809_-_---
Received on Mon Sep 05 2011 - 15:03:50 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:11 UTC