Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- T{
- left;
- right;
- parent;
- key;
- }root, node;
- TREE-INSERT-ROOT(T)
- Podaj root.key
- root.left=NIL
- root.right=NIL
- root.parent=NIL
- TREE-INSERT (T, node, root)
- Podaj node.key
- y = NIL
- x = T.root
- while x != NIL do
- y = x
- if node.key < x.key then x = x.left
- else x = x.right
- node.p = y
- if y == NIL then T.root = node
- else if node.key < y.key then y.left = node
- else y.right = node
- PREORDER-TREE-WALK (node)
- if node != NIL then
- if node.left=NIL or node.right=NIL then node.key=1
- else if node.left=NIL and node.right=NIL then node.key=2
- else node.key=0
- wypisz (node.key)
- PREORDER-TREE-WALK (node.left)
- PREORDER-TREE-WALK (node.right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement