Advertisement
Guest User

Untitled

a guest
Jan 12th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. type
  2. Pos = range[1'i16 .. high(int16)]
  3. Node = ref object
  4. word: string
  5. freq: Natural
  6. places: set[Pos]
  7. le, ri: Node
  8. Bst* = object
  9. root: Node
  10.  
  11. proc search(curr: Node, word: string): (Natural, set[Pos]) =
  12. if curr == nil:
  13. (0.Natural, {})
  14. elif word < curr.word:
  15. search(curr.le, word)
  16. elif word > curr.word:
  17. search(curr.ri, word)
  18. else:
  19. (curr.freq, curr.places)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement