I'm trying to build a Binary Search Tree. Below in my main method which reads from a file and inserts into the BST. However, I am getting an index out of bounds error and cannot figure out how to fix it. Any suggestion/solutions as to how it can be fixed?
public static void main(String[] args)
{
BinarySearchTree bst = new BinarySearchTree();
try
{
// you may modify the filepath, but not the filename
File file = new File("C:\\Users\\mbash\\Documents\\netflix_titles_alternative.csv");
Scanner token = new Scanner(file);
token.nextLine();
while(token.hasNext())
{
String line = token.nextLine();
String tmp[] = line.split(";");
String type = tmp[0];
String title = tmp[1];
int releaseYear = Integer.parseInt(tmp[2]);
bst.insert(type, title, releaseYear);
}
token.close();
}
catch(FileNotFoundException e)
{
System.out.println(e.getMessage());
System.exit(0);
}