**THIS PROBLEM IS IN JAVA** If a class is required to store data inside of a node, the getNode method that exists within

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

**THIS PROBLEM IS IN JAVA** If a class is required to store data inside of a node, the getNode method that exists within

Post by answerhappygod »

**THIS PROBLEM IS IN JAVA**
If a class is required to store data inside of a node, thegetNode method that exists within the node class is called. It willconfirm the presence of a node in the storage, and make a new nodeis one does not already exist in that storage. That same new nodeis then returned and the amount of nodes is incremented. On theother hand, if the storage list is not empty, the head is separatedfrom the list and updated to store the value of the head as aparameter, and the removed node is returned with the number ofnodes not being incremented. If a value is to be deleted, thereleaseNode method will be called on the node with that value,where it will change the value of the node to null and then placethe node at the head of the storage list.
This Problem Is In Java If A Class Is Required To Store Data Inside Of A Node The Getnode Method That Exists Within 1
This Problem Is In Java If A Class Is Required To Store Data Inside Of A Node The Getnode Method That Exists Within 1 (456.09 KiB) Viewed 66 times
A) Implement the getNode method: it should confirm if thestorage list is vacant, and create a new node with the samearguments and update the amount of nodes value while returning thenew node if true. On the other hand, if the list is not vacant,then remove the head of the list and then update the removed nodewith arguments while updating the head of the storage list. Returnthe node.
**HINT** THE CONSTRUCTOR IS: public static<E> Node<E> getNode(E it,Node<E> inn) {
B) implement releaseNode that will set the value ofthis.node equal to null while also adding it to the head of thelist.
**hint** THE CONSTRUCTOR IS: public void releaseNode(){
C) Implement getNumNodes that will return the amount ofnodes created.
public class Node<E> { private E e; // Value for this node private Node<E> next; // Point to next node in list // Constructor Node (E it, Node<E> inn) { e = it; next = inn; } public E element () { return e; } // Return the value public void setElement (E it) { e = it; } // Set element value public Node<E> next () { return next; } // Return next node public void setNext (Node<E> inn) { next = inn; } // Set next node. *****/ * Extensions to support storage list **/ private static Node storagelist = null; // storage list for the class. // define the number of nodes created // TO DO /** *Return a new node, from storage list if it is not empty * @param it - the value to be stored in the new node * @param inn - the follower of the new node * @return the node is empty, a new node is created, if not the head of the * storage list is used to store it **/ public static <E> Node <E> getNode (E it, Node<E> inn) { // TODO } * containing the value it. If the storage list // Return a node to the storage list public void releaseNode () { // TODO } // int get NumNodes () : Return the number of nodes created // TODO To create a new node of String (without a follower node) we write Node <String> n = Node.getNode ("Hello", null); and to release that same node we write n. release ();
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply