Built in Linked List Problems


Using :
private LinkedList<Integer> links = new LinkedList<Integer>();

Write the Following

  1. public int count( int num)
    //Count the number of times a particular int is in the list
  2. public Integer smallest()
    //return the smallest number in the list
  3. public int biggest()
    //return the biggest number in the list
  4. public void insert(int n)
    //insert number into an ascendingly ordered Linked List // precondition : the list is sorted in ascending order
  5. public Integer removeSmallest()
    //return the smallest number in the list
  6. public boolean removeNum(int num)
    //remove first occurrence of a number if there
  7. public void printReverse()
    // print list in reverse order
  8. public void removeDuplicates() // remove any duplicates
  9. public void move()
    // move first node in list to the end
  10. public void reverse()
    //reverse the list
  11. public LinkedList reverse()
    //return a new reversed list - don't disturb original
  12. int switcheveryother()
    // switch every other element // 1 3 8 5 3 9 -> 3 1 5 8 9 3