Guest User

Untitled

a guest
Jan 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. public TNode createTree (ASCIIDataFile in) {
  2. String c;
  3. TNode last_right = null;
  4. TNode tree = new TNode(null, null, in.readLine());
  5. while(in.isEOF()==false) {
  6. c = in.readLine();
  7. tree = insert(c, tree);
  8. }
  9. Rthread(tree);
  10. // System.out.println("-----------------------------------------");
  11. // Lthread(tree);
  12.  
  13. return tree;
  14. }
  15. public TNode insert ( String s, TNode t) {
  16. if (s != null) {
  17. if (t == null) {
  18. t = new TNode(null, null, s);
  19. }
  20. else if (s.compareTo(t.content) < 0 && t.ltag==false) {
  21. t.left = insert(s, t.left);
  22. }
  23. else if (s.compareTo(t.content) > 0 && t.rtag==false) {
  24. t.right = insert(s, t.right);
  25. }
  26. else {
  27. };
  28. }
  29. return t;
  30. }
Add Comment
Please, Sign In to add comment