Reference no: EM132117935
Queues, Lists, and Stacks Assignment:
Write client methods to do the following
Assume that there exists in main a list declared as :
List<Integer> aList = new List<Integer>(50);
Write a client method called bubbleSort which given a list as a parameter uses the bubble sort algorithm to sort the contents of the list.
YOU MAY ASSUME that there exists a method called swap (with the following signature) which swaps the contents of two elements:
// swap
public static void swap(List<Integer> list1, int position1, int position2)
The heading for the method should be:
public static void bubbleSort( List<Integer> list1)
Assume that in main there exists a queue declared as:
Queue<String> aQueue = new Queue<String>(50);
Write a client method called removeAll that given a String as a parameter removes all occurrences of the String from the queue, leaving the other values in the queue.
The heading for the method should be:
public static void removeAll(Queue<String> q1, String word)
Assume that in main there exists 2 queue's declared as:
Queue<String> aQueue = new Queue<String>(50);
Queue<String> bQueue = new Q<String>(50);
Write a client method called concatenate that concatenates two queues together and creating and returning a new queue.
the heading should be
public static Queue<String> concat( Queue<String> q1, Queue<String> q2)
Assuming that in main there exists a Stack declared as:
Stack<Integer> aStack = new Stack<Integer>(50);
Write a client method called reverseStack that given a stack as a parameter, reverses the contents of the stack. In this method you can declare additional instances of queues and stacks as needed.
Its heading should be:
public static void reverseStack(Stack<Integer> s1)
Assuming that in main there exists a Stack declared as:
Stack<Integer> aStack = new Stack<Integer>(50);
Write a client method called getLast that given a stack as a parameter, returns the value on the bottom of the stack, leaving the stack unchanged when the method is finished. In this method you can declare additional instances of queues and stacks as needed.
Its heading should be:
public static int getLast(Stack<Integer> s1)