Linked List Problems (member functions - Integer Objects)

All functions should access :

private ListNode first;
  1. public void createList(int n) // Create list of n random Integer Objects - use Math.random() - Objects should have values of 1 to 100
  2. public int count(int num)
    //Count the number of times a particular int is in the list
  3. public Integer smallest()
    //return the smallest number in the list
  4. public int biggest()
    //return the biggest number in the list
  5. public void insert(int n)
    //insert number into an ascendingly ordered Linked List
  6. public void removeSmallest()
    //remove the smallest number in the list
  7. public boolean removeNum(int num)
    //remove first occurrence of a number if there - return true or false
  8. public void printReverse()
    // print list reversed
  9. public void removeDuplicates() // remove any duplicates
  10. public void moveFirstToLast()
    // move first node in list to the end
  11. public void moveLastToFront()
    // move first node in list to the end
  12. public void reverse()
    //reverse the list
  13. public ListNode reverse()
    // return a new reversed list - first list not disturbed
  14. int switcheveryother()
    // switch every other element - in this one switch Values - leave addresses alone // 1 3 8 5 3 9 -> 3 1 5 8 9 3
  15. public ListNode getLocation(int n)
  16. Write a method lastIndexOf that takes an integer n as a parameter and that returns the index of the last occurrence of n in a list of integers and that returns -1 if n does not appear in the list.
    public int getlastIndexOf(int n)

Circular Linked List

  1. Create a circularly linked list with N random Integers (keep a pointer to the back)
  2. Print out the circularly linked list
  3. Implement a circularly linked list where you can either add or delete from the front or back (keep just one pointer to the back)
  4. Implement the list as a queue

Doubly Linked List

  1. Create a doubly linked list with N random Integers
  2. Keep a pointer to front and back. Add to either end. Print in either direction.
  3. Find a number and delete it
  4. Find a number and print 2 numbers in front of it (if there are 2)