run this code please and if there some syntax error fix ,
// 2D array
public class ExcelSheet {
int[][] exsheet;
int row;
int col;
public ExcelSheet(int r, int c) {
this.row = r;
this.col = c;
exsheet = new int[r][c];
}
// Insert an element E point at point (x, y)
public void insert(int x, int y, int value) {
exsheet[x][y] = value;
}
// Delete an element at point (x, y)
public void delete(int x, int y) {
exsheet[x][y] = 0;
}
// Find the element E
public int search(int x, int y) {
return exsheet[x][y];
}
}
// Binary Tree
public class ExcelSheetBin {
TNode root;
public ExcelSheetBin() {
root = null;
}
// Insert an element E point at point (x, y)
public void insert(int x, int y, int value) {
TNode node = new TNode(x, y, value);
if (root == null) {
root = node;
} else {
TNode temp = root;
while (temp != null) {
if (x < temp.x) {
if (temp.left == null) {
temp.left = node;
break;
} else {
temp = temp.left;
}
} else if (x > temp.x) {
if (temp.right == null) {
temp.right = node;
break;
} else {
temp = temp.right;
}
}
}
}
}
// Delete an element at point (x, y)
public void delete(int x, int y) {
TNode temp = root;
TNode parent = null;
while (temp != null) {
if (x == temp.x && y == temp.y) {
if (parent == null) {
root = null;
} else if (parent.left == temp) {
parent.left = null;
} else {
parent.right = null;
}
break;
} else if (x < temp.x) {
parent = temp;
temp = temp.left;
} else {
parent = temp;
temp = temp.right;
}
}
}
// Find the element E
public int search(int x, int y) {
TNode temp = root;
while (temp != null) {
if (x == temp.x && y == temp.y) {
return temp.value;
} else if (x < temp.x) {
temp = temp.left;
} else {
temp = temp.right;
}
}
return 0;
}
}
class TNode {
int x;
int y;
int value;
TNode left;
TNode right;
public TNode(int x, int y, int value) {
this.x = x;
this.y = y;
this.value = value;
left = null;
right = null;
}
}
public class Main {
public static void main(String[] args) {
// 2D Array
ExcelSheet sheet2D = new ExcelSheet(2, 3);
sheet2D.insert(0, 0, 1);
sheet2D.insert(0, 1, 2);
sheet2D.insert(0, 2, 3);
sheet2D.insert(1, 0, 4);
sheet2D.insert(1, 1, 5);
sheet2D.insert(1, 2, 6);
sheet2D.delete(0, 0);
System.out.println(sheet2D.search(0, 0));
System.out.println(sheet2D.search(1, 2));
// Binary Tree
ExcelSheetBin SheetBin = new ExcelSheetBin();
SheetBin.insert(1, 1, 1);
SheetBin.insert(2, 2, 2);
SheetBin.insert(3, 3, 3);
SheetBin.insert(4, 4, 4);
SheetBin.delete(2, 2);
System.out.println(SheetBin.search(2, 2));
System.out.println(SheetBin.search(3, 3));
}
}
=========
take screenshot please
sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facili
sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus,
sectUnlock access to this and over
10,000 step-by-step explanations
Have an account? Log In
sectetur adipiscing elit. Nam l
sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis.
sectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante,