83fd39c20d7d48eb3941f5666938abee
<div class=""><div style="font-family:'helvetica neue', helvetica, arial;color:#333333;">
<div>need the answers to these recursive practice problems using
linked lists in java . thank you.</div>
<div><br/>
<img src="//img.homeworklib.com/images/268f3ede-a3ce-4c98-a966-9de282e25209.png" alt="complete the link class by writing methods described below. do not use loops, or create any more methods (other than those sp" aria-describedby="chf"/>
</div>
<div><img src="//img.homeworklib.com/images/918beeb7-509b-41b7-a48a-d1614b0c3a73.png" alt="2. write a recursive instance method issorted that takes a link parameter and determines whether a linked list is sorted in d" aria-describedby="chg"/></div>
</div>
<div id="chf" class="hidden">complete the link class by writing methods described below. do not use loops, or create any more methods (other than those specified), class or instance variables. public class link private link next; /null if this is the last link private int value; public link(link n, int v) nextn valuev; do not use loops, or create any more methods (other than those specified), class or instance variables. 1. write a recursive instance method count that takes no parameters and returns an int. return the number of links that hold the value zero, with the exception that the last link in the list is not included in the count. for example, for the linked list, {(first) 5→0→3→1→0→0 (last)) it would return the value 2. </div><div id="chg" class="hidden">2. write a recursive instance method issorted that takes a link parameter and determines whether a linked list is sorted in descending order or not (retun a boolean value). 3. write a recursive instance method named findbad that takes no parameters and returns a reference to a link. the result of calling findbad is a reference to the first link that has a value greater than the next link's value. if no such link exists return null. for example, for {5→6→7→3→2) it would return a reference to the third link ("7"). </div></div>
 <span class="transcribed-image-text">complete the link class by writing methods described below. do not use loops, or create any more methods (other than those specified), class or instance variables. public class link private link next; /null if this is the last link private int value; public link(link n, int v) nextn valuev; do not use loops, or create any more methods (other than those specified), class or instance variables. 1. write a recursive instance method count that takes no parameters and returns an int. return the number of links that hold the value zero, with the exception that the last link in the list is not included in the count. for example, for the linked list, {(first) 5→0→3→1→0→0 (last)) it would return the value 2. <br/>
2. write a recursive instance method issorted that takes a link parameter and determines whether a linked list is sorted in descending order or not (retun a boolean value). 3. write a recursive instance method named findbad that takes no parameters and returns a reference to a link. the result of calling findbad is a reference to the first link that has a value greater than the next link's value. if no such link exists return null. for example, for {5→6→7→3→2) it would return a reference to the third link ("7"). </span>
need the answers to these recursive practice problems using linked lists in java . thank you. complete the link cl...
homeworklib.com
2019.51
<p>//java program</p>
<p>class link{<br/>
   private link next;<br/>
   private int value;<br/>
  <br/>
   public link(link n , int v) {<br/>
       next = n;<br/>
       value = v;<br/>
   }<br/>
   public link getnext() {<br/>
       return next;<br/>
   }<br/>
   public void setnext(link n) {<br/>
       next = n;<br/>
   }<br/>
   public int getvalue() {<br/>
       return value;<br/>
   }<br/>
   public void setvalue(int v) {<br/>
       value = v;<br/>
   }<br/>
}<br/>
class linklist{<br/>
   private link head;<br/>
  <br/>
   private int countrec(link node) {<br/>
      
if(node==null||node.getnext()==null)return 0;<br/>
       if(node.getvalue()==0)return 1 +
countrec(node.getnext());<br/>
       else return
countrec(node.getnext());<br/>
      <br/>
   }<br/>
   private link findbadrec(link node) {<br/>
      
if(node==null||node.getnext()==null)return null;<br/>
      
if(node.getvalue()>node.getnext().getvalue())return node;<br/>
       else return
findbadrec(node.getnext());<br/>
   }</p>
<p>  <br/>
   public linklist() {<br/>
       head = null;<br/>
   }<br/>
   public void append(int data) {<br/>
       link node = new
link(null,data);<br/>
       if(head==null) {<br/>
           head =
node;<br/>
           return;<br/>
       }<br/>
       link current = head;<br/>
      
while(current.getnext()!=null)current = current.getnext();<br/>
       current.setnext(node);<br/>
   }<br/>
  <br/>
   public void print() {<br/>
       link current = head;<br/>
       while(current!=null) {<br/>
          
system.out.print(current.getvalue()+" ");<br/>
           current =
current.getnext();<br/>
       }<br/>
       system.out.println();<br/>
   }<br/>
  <br/>
   public int count() {<br/>
       return countrec(head);<br/>
   }<br/>
  <br/>
   public link findbad() {<br/>
       return findbadrec(head);<br/>
   }<br/>
  <br/>
}</p>
<p>public class linkedlistt {<br/>
   public static void main(string args[]) {<br/>
       linklist list = new
linklist();<br/>
       list.append(5);<br/>
       list.append(6);<br/>
       list.append(7);<br/>
       list.append(3);<br/>
       list.append(2);<br/>
      <br/>
      
system.out.println(list.findbad().getvalue());<br/>
      <br/>
      <br/>
   }<br/>
  <br/>
   public static boolean issorted(link node) {<br/>
      
if(node==null||node.getnext()==null)return true;<br/>
      
if(node.getvalue()>=node.getnext().getvalue())return
issorted(node.getnext());<br/>
       return false;<br/>
   }<br/>
}<br/></p>