Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note
- description: "Summary description for {BIN_TREE}."
- author: ""
- date: "$Date$"
- revision: "$Revision$"
- class
- BIN_TREE [G]
- create
- make
- feature -- attributes
- left : detachable BIN_TREE [G]
- right : detachable BIN_TREE [G]
- info : G
- feature -- creation procedures
- make (arg1: G )
- do
- info:= arg1
- end
- feature -- queries
- height : INTEGER
- do
- if (not attached left) and (not attached right) then
- Result:=1
- end
- if attached left as L then
- Result := L.height + 1
- end
- if attached right as R then
- if R.height > Result then
- Result := R.height + 1
- end
- end
- end
- feature -- procedures
- add_left(t : BIN_TREE [G]) -- replace left subtree by new one
- do
- if attached t as L then
- left := L
- end
- end
- add_right(t : BIN_TREE [G]) -- replace right subtree by new one
- do
- if attached t as R then
- right := R
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement