Results 1 to 3 of 3
- 04-20-2011, 02:00 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
how to read list of name from text file into a binary search tree?
As the title, how to read data from text file and load into a BST? suppose text file have name and phone number which name and phone number is a string, so when function invoked should read data from text file and load into a BST
having problem with this,Java Code:public void readDataFile() // read data from text fiel and load into BST { String fileName = "phonebook.txt"; // name of thr file Scanner fromFile = null; try{ fromFile = new Scanner(new File(fileName)); // read from file phonebook.txt } catch(FileNotFoundException e) { System.out.println("Error : " +e); System.out.println("Unable to open file " + fileName); } DataFile tree = new DataFile(); while (fromFile.hasNextLine()) { String line = fromFile.nextLine(); // reads each line from the text file and stores it in line. tree.add(line); // please help me this part } fromFile.close(); }is the "add" suppose a function? or have any standard library command to replace it?Java Code:tree.add(line)
- 04-20-2011, 05:33 PM #2
Member
- Join Date
- Feb 2011
- Posts
- 18
- Rep Power
- 0
am i posting on the wrong section? or no one seems to know how to correct it?
- 04-20-2011, 05:39 PM #3
Member
- Join Date
- Dec 2009
- Posts
- 36
- Rep Power
- 0
this should help you, i guess you don't understand what a binary search tree is?
Java binary tree code
Similar Threads
-
Data Structures(Binary Search Tree to AVL Tree)ASAP pls
By jfAdik in forum Forum LobbyReplies: 0Last Post: 04-04-2010, 07:40 AM -
Binary search tree search method
By chopo1980 in forum New To JavaReplies: 2Last Post: 12-10-2009, 01:42 AM -
Binary Search Tree
By anmadie in forum New To JavaReplies: 5Last Post: 11-17-2009, 02:39 AM -
Binary Search Tree
By Goo in forum New To JavaReplies: 0Last Post: 03-06-2009, 04:46 PM -
Binary Search Tree
By michael_mke in forum New To JavaReplies: 3Last Post: 12-04-2008, 02:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks