import java.io.*; // for keyboard io // more binary trees and search trees, plus sample on how to do IO public class nov16 { public static boolean iter_instree(int x, node T) { boolean temp = false; node current = T; while ((current != null) && (!temp)) { if (x == current.head) temp = true; else if (x min)) return ( bounded(T.left,min,T.head) && bounded(T.right,T.head,max) ); else return false; } // end bounded /* bounded can be simplified into return ((T == null) || ((T.head <= max) && (T.head > min) && bounded(T.left,min,T.head) && bounded(T.right,T.head,max)); */ /* delete from search tree: find node, replace with right branch, find left most leaf of right branch, insert left branch. */ public static node delete(int x, node T) { if (T == null) return null; else if (xT.head) return new node(T.head,T.left,delete(x,T.right)); else // x==T.head return attach(T.left,T.right); } // end delete // attach A to left of leftmost leaf of B: private static node attach(node A, node B) { if (B == null) return A; return new node(B.head, attach(A,B.left), B.right); } // how would you delete from general tree? public static void main(String[] args) { String S = "adfsd"; // make sure S not null try { FileInputStream fis = new FileInputStream("testfile"); InputStreamReader isr = new InputStreamReader(fis); // file IO // InputStreamReader isr = new InputStreamReader(System.in); // keyboard IO BufferedReader filereader = new BufferedReader(isr); while (S !=null) // S will be null at end of file { S = filereader.readLine(); // read a string System.out.println("The string in file is " + S); } } catch (Exception E) {} } // end main } // end class nov16 class node { int head; node left; node right; public node(int h, node l, node r) { head = h; left = l; right = r; } } // end class node class cell { int head; cell tail; public cell(int h, cell t) { head = h; tail = t; } }