Question: [JAVA] Please help me with writing methods for this assignment. The questions are posted below followed by the segment of code that needs to be

[JAVA] Please help me with writing methods for this assignment. The questions are posted below followed by the segment of code that needs to be modified. Thanks.

[JAVA] Please help me with writing methods for this assignment. The questions

are posted below followed by the segment of code that needs to

be modified. Thanks. package lab8; import java.io.File; public class Lab8App { public

static void main(String[] args) { Lab8App recursion = new Lab8App(); System.out.println(recursion.strToNum("12341")); System.out.println(recursion.findMin(new

int[] {3,2,1,4,5}, 5, 0)); System.out.println(recursion.isPalindrome("racecar", 0, 6)); System.out.println(recursion.reverseString("pots&pans")); recursion.traverse(new File("J:/")); recursion.hanoi(4); LinkedList

package lab8; import java.io.File; public class Lab8App { public static void main(String[] args) { Lab8App recursion = new Lab8App(); System.out.println(recursion.strToNum("12341")); System.out.println(recursion.findMin(new int[] {3,2,1,4,5}, 5, 0)); System.out.println(recursion.isPalindrome("racecar", 0, 6)); System.out.println(recursion.reverseString("pots&pans")); recursion.traverse(new File("J:/")); recursion.hanoi(4); LinkedList ulist = new LinkedList(); String[] str = {"hello","this","is","a","test"}; for(String s : str) ulist.insert(s); System.out.println(ulist); Node node = ulist.getfront(); System.out.println(recursion.countNodes(node)); } public int strToNum(String str) { if(str.length() = 0. * In addition, write the recursive method. */ /* * 4. Write a recursive method to display the contents of a linked-list in reverse order. */ /* * 5. Write a recursive method to convert a number, n, to a base, b, and return result as a String. */ } class Node{ private E data; private Node next; public Node(){ data = null; next = null; } public Node(E d){ data = d; next = null; } public Node(E d, Node n){ data = d; next = n; } public Node getNext(){ return next; } public void setNext(Node n){ next = n; } public E getData() { return data; } public void setData(E data) { this.data = data; } } class LinkedList>{ protected Node head = new Node(); // dummy Node protected int numItems; public Node getfront(){ return head.getNext(); } public int getSize(){ return numItems; } public boolean isEmpty(){ return numItems == 0; } public void insert(T insertItem) { if(insertItem == null) throw new NullPointerException(); Node trav = head; while(trav.getNext() != null) trav = trav.getNext(); trav.setNext(new Node(insertItem)); ++numItems; } public String toString(){ String str = " ================================== " + "The list contains " + numItems + " items. " + "================================== ["; Node trav = head.getNext(); while(trav != null){ // str += trav.data + " "; str += trav.getData() + ((trav.getNext() == null) ? "" : "->"); trav = trav.getNext(); } return str + "]"; } }
package lab8; public class Factorial { public static void main(String[] args) { int n = 20; int factorial = 1; int i = 1; while (i   Write a recursive method for converting a string of digits into the integer it represents. For example, "12341 represents the integer 12341. Hint: Process the string left to right. public int strToNum (String str) ( if(str.length)1) return 0 else return ((str.charAt (str.length() - 1)-0') + (10 * strToNum(str.substring (0, str.length) - 1)))); Write a recursive method that counts the number of nodes in a singly linked list. private int countNodes (Node trav) if (trav null) return 0 return 1 countNodes (trav.next)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!