Linked List Problems (member functions - Integer Objects)
All functions should access :
private ListNode first;
-
public void createList(int n) // Create list of n random Integer Objects - use Math.random() - Objects should have values of 1 to 100
-
public int count(int num)
//Count the number of times a particular int is in the list
-
public Integer smallest()
//return the smallest number in the list
-
public int biggest()
//return the biggest number in the list
-
public void insert(int n)
//insert number into an ascendingly ordered Linked List
-
public void removeSmallest()
//remove the smallest number in the list
-
public boolean removeNum(int num)
//remove first occurrence of a number if there - return true or false
-
public void printReverse()
// print list reversed
-
public void removeDuplicates()
// remove any duplicates
-
public void moveFirstToLast()
// move first node in list to the end
-
public void moveLastToFront()
// move first node in list to the end
-
public void reverse()
//reverse the list
-
public ListNode reverse()
// return a new reversed list - first list not disturbed
-
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
-
public ListNode getLocation(int n)
-
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
-
Create a circularly linked list with N random Integers (keep a pointer to the back)
-
Print out the circularly linked list
-
Implement a circularly linked list where you can either add or delete from the front or back (keep just one pointer to the back)
-
Implement the list as a queue
Doubly Linked List
-
Create a doubly linked list with N random Integers
-
Keep a pointer to front and back. Add to either end. Print in either direction.
-
Find a number and delete it
-
Find a number and print 2 numbers in front of it (if there are 2)
|