I get this error in my code regarding lines 33 and 40. Can someone show my how to correctly code this in java

I get this error in my code regarding lines 33 and 40. Can someone show my how to correctly code this in java.

import java.util.Scanner;
import java.io.*;

public class BinaryStringTree {

private String data;
private BinaryStringTree first;
private BinaryStringTree last;

public void BinaryStringTree() { // default constructor
this.data = null;
this.first = null;
this.last = null;
}

public void BinaryStringTree(String data) { // parameterized constructor
this.data = data;
this.first = null;
this.last = null;
}

public void inNode(String data) {
if (this.data == null) { // If the tree is empty, place the data into root node
this.data = data;
} else {
if(this.data.compareTo(data) == 0) {
System.out.println(“word already in Binary String Tree” ); // No duplicate are allowed
}
else if (this.data.compareTo(data) < 0) { // If string to be inserted is lexicographically smaller than root.data, then iterate towards left subtree if (this.first != null) { this.first.inNode(data); } else { this.first = new inNode(data); } } else { // Else If string to be inserted is lexicographically greater than or equal to root.data, then iterate towards right subtree if (this.last != null) { this.last.inNode(data); } else { this.last = new inNode(data); } } } } public void inOrd() { // Inorder traversal of the tree if (this.first != null) { this.first.inOrd(); } System.out.println(this.data); if (this.last != null) { this.last.inOrd(); } } public static void search(BinaryStringTree root, String s) { int count = 0; while(root != null) { count++; if(s.compareTo(root.data) > 0) {
root = root.last;
}
else if(s.compareTo(root.data) < 0) { root = root.first; } else { System.out.println("Inspected " + count + " elements"); System.out.println(s + " located"); return; } } System.out.println("Inspected " + count + " elements"); System.out.println(s + " not in tree");} public static String minimum(BinaryStringTree root) { String min = root.data; while( root.first != null) { min = root.first.data; root = root.first;} return min;} public static BinaryStringTree remove(BinaryStringTree root, String s) { if(root==null) return null; if(s.compareTo(root.data) < 0) { // If str is lexicographically smaller than root.data, then iterate towards left subtree root.first = remove(root.first, s);} else if(s.compareTo(root.data) > 0) // If str is lexicographically greater than root.data, then iterate towards right subtree
root.last = remove(root.last, s);
else {
if(root.first == null)
return root.last;
else if(root.last == null)
return root.first;
root.data = minimum(root.last); //Get the inorder successor (smallest in the right subtree)
root.last = remove(root.last, root.data); // Delete the inorder successor
}
return root;}
public static void main(String[] args){
File f = new File(“text.in”);
Scanner scnr = new Scanner(f);
BinaryStringTree bst = new BinaryStringTree();
while (scnr.hasNext()) {
String word = scnr.next();
bst.inNode(word);}
while(true) {
System.out.println(“Enter string, enter -1 to quit”);
String s= scnr.nextLine();
if(s.compareTo(“-1”) == 0)
break;
search(bst, s);}
while(true) {
System.out.println(“Enter string to remove”);
String s= scnr.nextLine();
if(s.compareTo(“-1”) == 0)
break;
remove(bst, s);
bst.inOrd();
}
}
}

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?