как сделать вставить случайное целое число от 1 до 10000 в дерево ?? Я только с помощью scanner.in в коде нижереализовать двоичное дерево и сделать его сбалансированным
private BinaryTree insert(BinaryTree node, int value)
{
if (node == null)
node = new BinaryTree(value);
else
{
if (value <= node.getValue())
node.left_child = insert(node.left_child, value);
else
node.right_child = insert(node.right_child, value);
}
return node;
}
государственной статической силы основных (String [] арг)
do
{
//tree operations
System.out.println("\nTree Operations\n");
System.out.println("1. insert ");
int choice = scan.nextInt();
switch (choice)
{
case 1 :
System.out.println("get integer element to insert");
bst.insert(scan.nextInt());
break;
default :
System.out.println("Wrong Entry \n ");
break;
}
В чем проблема? Вы получаете сообщение об ошибке? Неправильный результат? – Mureinik
Я думаю, вам нужно переосмыслить, как вы внедряете свой BT –