Advertisement
Guest User

Binary Search Tree Search (Recursion) Function

a guest
Nov 15th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Binary Search Tree Search (Recursion) Function
  2.  
  3. searchedNode equals the node you're looking for
  4. currentNode equals the middle of the list
  5. recursionFunction(searchedNode, currentNode):
  6. if, list has contents:
  7. if, searched node equals currentNode:
  8. inform user the searchedNode is in the list (or do whatever)
  9. else if, searchedNode is greater than currentNode:
  10. if, the currentNode has no pointer to a greater number:
  11. inform user the searchedNode is not in the list (or do whatever)
  12. else:
  13. call recursionFunction(searchedNode, currentNode.more)
  14. else if, searchedNode is less that currentNode:
  15. if, the currentNode has no pointer to a lesser number:
  16. inform user the searchedNode is not in the list (or do whatever)
  17. else:
  18. call recursionFunction(searchedNode, currentNode.less)
  19. else:
  20. inform user that the list is empty
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement