home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
-
-
- PRODUCT : TURBO PASCAL TUTOR NUMBER : 317
- VERSION : 2.00
- OS : PC-DOS
- DATE : July 17, 1986 PAGE : 1/3
- TITLE : RECURSION MODIFICATIONS
-
-
-
-
- The following is a list of modifications to be made to the file
- RECUR.EX in version 2.0 of the Turbo Pascal Tutor. The changes
- prevent the program from hanging after deleting the root of the
- binary tree.
-
- NOTE: This code modification updates your version of the Turbo
- Pascal Tutor to version 2.00A.
-
- 1. Make a backup copy of the file RECUR.EX.
- 2. Load the file RECUR.EX into the Turbo Pascal editor.
- 3. In the function LeftNode:
-
- Change from:
- .
- .
- .
- LeftNode := Node^.Parent^.Left = Node;
- .
- .
- .
- Change to:
- .
- .
- .
- LeftNode := (Node^.Parent^.Left = Node) or (Node = nil);
- { Ver. 2.00A }
- . { Modification }
- .
- .
-
- 4. In the procedure LeftAndRightNil, change from:
- .
- .
- .
- if LeftNode(Node) then
- Node^.Parent^.Left := Nil
- else
- Node^.Parent^.Right := Nil
- .
- .
- .
-
- Change to:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : TURBO PASCAL TUTOR NUMBER : 317
- VERSION : 2.00
- OS : PC-DOS
- DATE : July 17, 1986 PAGE : 2/3
- TITLE : RECURSION MODIFICATIONS
-
-
-
-
- .
- .
- .
- if Node <> Root then { Ver. 2.00A Addition }
- begin { Ver. 2.00A Addition }
- if LeftNode(Node) then
- Node^.Parent^.Left := Nil
- else
- Node^.Parent^.Right := Nil
- end; { Ver. 2.00A Addition }
- .
- .
- .
-
- 5. In the procedure LeftNil, change from:
- .
- .
- .
- if LeftNode(Node) then
- Node^.Parent^.Left := Node^.Right
- else
- Node^.Parent^.Right := Node^.Right;
- .
- .
- .
- Change to:
- .
- .
- .
- if Node <> Root then { Ver. 2.00A Addition }
- begin { Ver. 2.00A Addition }
- if LeftNode(Node) then
- Node^.Parent^.Left := Node^.Right
- else
- Node^.Parent^.Right := Node^.Right;
- end; { Ver. 2.00A Addition }
- .
- .
- .
-
- 6. In the procedure RightNil, change from:
- .
- .
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PRODUCT : TURBO PASCAL TUTOR NUMBER : 317
- VERSION : 2.00
- OS : PC-DOS
- DATE : July 17, 1986 PAGE : 3/3
- TITLE : RECURSION MODIFICATIONS
-
-
-
-
- .
- if LeftNode(Node) then
- Node^.Parent^.Left := Node^.Left
- else
- Node^.Parent^.Right := Node^.Left;
- .
- .
- .
- Change to:
- .
- .
- .
- if Node <> Root then { Ver. 2.00A Addition }
- begin { Ver. 2.00A Addition }
- if LeftNode(Node) then
- Node^.Parent^.Left := Node^.Left
- else
- Node^.Parent^.Right := Node^.Left;
- end; { Ver. 2.00A Addition }
- .
- .
- .
-
- 7. Save the file.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-