-4

instance variables assignment

package projects;

public class Node {//Node class
    int data;
    Node next;
    Node leftNode;
    Node rightNode;        
}

public class Tree {//Tree class
    if (node.data < root.data) {
        focusNode = focusNode.leftNode; //what does this assignment mean //exactly
    }
}

This is the code snippet I need help on, please help thanks in advance.

Bentaye
  • 9,403
  • 5
  • 32
  • 45
  • I'm not sure it's a duplicate of references and object. The main problem could be an (lack of) understanding of [linked lists](https://en.wikipedia.org/wiki/Linked_list). – Roger Gustavsson Aug 01 '19 at 08:05

1 Answers1

0

It looks like the code you are asking about is missing its type and should be (see second to last line):

package projects;

public class Node {//Node class
    int data;
    Node next;
    Node leftNode;
    Node rightNode;        
}

public class Tree {//Tree class
    if (node.data < root.data) {
        Node focusNode = focusNode.leftNode; 
    }

This looks like a self-referencing node for a Tree storage system.

It is comparing the data of the present node to the root (assumedly the parent of the node) so that you can add the node to either the left or right side of the tree.

user11809641
  • 815
  • 1
  • 11
  • 22