Question: Data structures: java 9. On the last page of these review problems is an implementation of the IntNode class (a) Write an implementation of the
Data structures: java
9. On the last page of these review problems is an implementation of the IntNode class (a) Write an implementation of the static method public static int countZeros( IntNode node) that will count the number of zeros that occur in the given linked list of ints (b) Write an implementation of a static method public static String list2String( IntNode node ) that returns a String representation of the linked list referred to by the parameter node. If the linked list is empty, the String representation should be "[]" (two square brackets next to each other). If the linked list is not empty, the String representation should look like this, "C 3 52 0 2 -4 16 ]", with a space before and after each entry of the list. (c) Write a method public static IntNode removeFirst IntNode head ) that returns a reference to the second node from the linked list referred to by the parameter head (d) Write a methood public static IntNode addFirst( int element, IntNode head) that returns a reference to the new head of a linked list with a node containing element followed by the list referred to by the parameter head (e) Write a method public static void set( int element, int i, IntNode head ) that modifies the list referred to by the parameter head so that the i'th node in the list has its data changed to element. If there is no i'th node in the list, then the list is not modified
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
