//------------// Introduction to Programming Using Java: An Object-Oriented Approach//	Arnow/Weiss//------------// the search method// Chapter 11, Section 11.5, Page 477// MODIFICATIONS://    bsearch is made static here so we//    can test it without creating an object//    main creates a Vector of Strings from input and then tests to see if//	each String can be found in the Vector.import java.io.*;import java.util.*;class Testbsearch {	//  Returns true if s is among v[first], ..., v[beyond-1]	static boolean  bsearch(String s, Vector  v,  int  first,  int  beyond)  {		if  (first>=beyond)			return  false;		int  m  =  (first+beyond)/2;		String sm  =  (String)  v.elementAt(m);		if  (sm.compareTo(s)<0)			return  bsearch(s,v,m+1,beyond);		if  (sm.compareTo(s)>0)			return  bsearch(s,v,first,m);		return  true;	}	public static void main(String[] a) throws Exception {		boolean fails=false;		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));		v = new Vector();		String line = f.readLine();		String huge = "";		while (line != null) {			huge = huge.concat(line);			v.addElement(line);			line = f.readLine();		}		Enumeration e = v.elements();		while (e.hasMoreElements()) {			System.out.print((String)e.nextElement());			System.out.print(" ");		}		System.out.println();		int m=0;		while (m!=v.size()) {			String s = (String) v.elementAt(m);			System.out.println(s+" "+bsearch(s,v,0,v.size()));			m++;		}		int k=0;		while (k != v.size()) {			fails |= !bsearch((String)v.elementAt(k),v,0,v.size());			k++;		}		fails |= bsearch(huge,v,0,v.size());		if (fails)			System.out.println("search fails these tests");		else			System.out.println("search passes these tests");	}	static Vector v;}// Sample test input (must be sorted!)// antidisestablishmentarianism// abc// butter// butter// ketchup// mustard// x// z