Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public TNode createTree (ASCIIDataFile in) {
- String c;
- TNode last_right = null;
- TNode tree = new TNode(null, null, in.readLine());
- while(in.isEOF()==false) {
- c = in.readLine();
- tree = insert(c, tree);
- }
- Rthread(tree);
- // System.out.println("-----------------------------------------");
- // Lthread(tree);
- return tree;
- }
- public TNode insert ( String s, TNode t) {
- if (s != null) {
- if (t == null) {
- t = new TNode(null, null, s);
- }
- else if (s.compareTo(t.content) < 0 && t.ltag==false) {
- t.left = insert(s, t.left);
- }
- else if (s.compareTo(t.content) > 0 && t.rtag==false) {
- t.right = insert(s, t.right);
- }
- else {
- };
- }
- return t;
- }
Add Comment
Please, Sign In to add comment