I'm making a LinkedList class and have to make certain methods for it. I don't know quite what to do for this one by the description I'm given: "Object initTraversal() Initialize a private instance variable to point to the first Node in the list (or null if the list is empty). Return the item in the first Node (if the list is not empty) or else return null." I don't get the initialize a private instance variable to point to the first Node part. Do I make a whole new node and make it link to my "first" node? If I have to return the item in the first node, why don't I just return first.da
What language are you working in? But you shouldn't need to create a whole new node. You'll just need to have a variable that says where the first node is (in C, it'd be a pointer, in Java a reference variable).
Join our real-time social learning platform and learn together with your friends!