12.2

  1.  
    public boolean contains (int item)
    { 
       Node current = head;
       boolean found = false; 
       while (!found && current != null)
          if (current.info == item) 
             found = true; 
          else 
             current = current.link;
       return found;
    } 
  2. No. We can't jump to the middle of a linked list as we can with an array.
  3.  
    public void deleteAll (int item)
    { 
       // First delete any values at the front of list
       while (head != null && head. info == item) 
          head = head. link; 
       // Now delete any items not at the front of the list
       if (head != null && head.link != null) 
       { 
          Node current = head.link;
          Node previous = head;
          while (current != null) 
             if (current.info == item) 
             { 
                pevious.link = current.link;
                current = current.link;
             } 
             else 
             { 
                previous = current;
                current = current.link;
             }
       }
    } 
  4.  
    public boolean isOrderedlncreasing ()
    { 
       boolean result = true;
       if (head != null) 
       { 
          Node previous = head;
          Node current = head.link;
          while (current != null && result)
            if (current.info.compareTo(previous.info) <= 0)
               result = false; 
            else
            { 
               previous = current;
               current = current.link;
            }
       }
    } 
  5.  
    public void insert(int item)
    { 
       if (head == null) 
          head = new Node(item,null);
       else if (item < head. info) 
          head = new Node(item,head);
       else
       { 
          // Locate insertion point
          Node current = head;
          boolean located = false; 
          while (!located && current.link != null)
          if (item < current.link.info)
             located = true; 
          else
             current = current.link;
          // Perform insertion 
          if (located) // Normal insertion
          { 
             Node temp = new Node(current.info,current.link);
             current.info = item; 
             current.link = temp; 
          } 
          else // Insert at end of list
             current.link = new Node(item,null); 
       }
    } 
  6.  
    public boolean isIdentical (List other)
    { 
       if (other == null)
          return false;
       else if (head == null && other.head == null)
          return true; 
       else if (head == null || other.head == null)
          return false; 
       else 
       {
          Node current = head; 
          Node otherCurrent = other.head;
          while (true) 
          { 
             if (current.info != otherCurrent.info)
                return false; 
             else if (current.link == null && otherCurrent.link == null)
                return true; 
             else if (current.link == null || otherCurrent.link == null)
                return false; 
             else 
             {
                current = current.link;
                otherCurrent = otherCurrent.link; 
             }
          }
       }
    }