Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- isSameDepth(T):
- from = NIL
- x = T.root
- absolute_d = uninitialized
- d = 0
- while x != NIL do
- if from == x.parent then
- if x.c[1] == NIL then
- if absolute_d == uninitialized then
- absolute_d = d
- to = RETURN_TO_PARENT
- else if d == absolute_d then
- to = RETURN_TO_PARENT
- else
- return false
- else
- d++
- to = 1
- else
- for i = 1 to 99 do
- if x.c[i] == from then
- if x.c[i + 1] == NIL then
- d--
- to = RETURN_TO_PARENT
- else
- to = i + 1
- from = x
- if to == RETURN_TO_PARENT then
- x = x.parent
- else
- x = x.c[to]
- return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement