Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1.  
  2.  
  3. isSameDepth(T):
  4. from = NIL
  5. x = T.root
  6. absolute_d = uninitialized
  7. d = 0
  8. while x != NIL do
  9. if from == x.parent then
  10. if x.c[1] == NIL then
  11. if absolute_d == uninitialized then
  12. absolute_d = d
  13. to = RETURN_TO_PARENT
  14. else if d == absolute_d then
  15. to = RETURN_TO_PARENT
  16. else
  17. return false
  18. else
  19. d++
  20. to = 1
  21. else
  22. for i = 1 to 99 do
  23. if x.c[i] == from then
  24. if x.c[i + 1] == NIL then
  25. d--
  26. to = RETURN_TO_PARENT
  27. else
  28. to = i + 1
  29. from = x
  30. if to == RETURN_TO_PARENT then
  31. x = x.parent
  32. else
  33. x = x.c[to]
  34.  
  35. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement