SHARE
TWEET

BIN_TREE

a guest Oct 8th, 2018 127 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. note
  2.     description: "Summary description for {BIN_TREE}."
  3.     author: ""
  4.     date: "$Date$"
  5.     revision: "$Revision$"
  6.  
  7. class
  8.     BIN_TREE [G]
  9.  
  10. create
  11.     make
  12.  
  13. feature -- attributes
  14.     left : detachable BIN_TREE [G]
  15.     right : detachable BIN_TREE [G]
  16.     info : G
  17.  
  18. feature -- creation procedures
  19.     make (arg1: G )
  20.         do
  21.             info:= arg1
  22.         end
  23. feature -- queries
  24.     height : INTEGER
  25.         do
  26.             if (not attached left) and (not attached right) then
  27.                 Result:=1
  28.             end
  29.             if (attached left) and then left.height > Result then
  30.                 Result := left.height + 1
  31.             end
  32.             if (attached right) and then right.height > Result then
  33.                 Result := right.height + 1
  34.             end
  35.         end
  36.  
  37. feature -- procedures
  38.     add_left(t : BIN_TREE [G]) -- replace left subtree by new one
  39.         do
  40.             if attached t as L then
  41.                 left := L
  42.             end
  43.  
  44.         end
  45.     add_right(t : BIN_TREE [G]) -- replace right subtree by new one
  46.         do
  47.             if attached t as R then
  48.                 right := R
  49.             end
  50.         end
  51. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top