Stacks-Queues-and-Linked-Stacks-computer-science-homework-help

For the next problems write a client to test the following methods. Check out the lecture notes(attached) for the necessary files(StackADT.java, LinkedStackClass.java, QueueADT.java, QueueClass.java, QueueException.java, QueueOverflowException.java, andQueueUnderflowException.java.) 

1. (Method: printBackStack) Task: Display the contents of a stack in reverse order (top to bottom), leaving the stack unchanged.

SOLUTION:

     public static void printBackStack(LinkedStackClass<Integer> intStack) {_x000D_
         ..._x000D_

}2. (Method: printStack) Task: Display the contents of a stack in direct order (bottom to top), leaving

the stack unchanged.

SOLUTION:

      public static void printStack(LinkedStackClass<Integer> intStack) {_x000D_
          ..._x000D_

}3. (Method: getSecond) Task: Find the second item in a stack, leaving the stack unchanged.

SOLUTION:

      public static Integer getSecond(LinkedStackClass<Integer> intStack) {_x000D_
          ..._x000D_

}

4. (Method: countItems) Task: Count the number of items in a stack, leaving the stack unchanged. SOLUTION:

     public static int countItems(LinkedStackClass<Integer> intStack) {_x000D_
        ..._x000D_

}5. (Method: removeItem) Task: Delete every occurrence of a specified item from a stack, leaving the

order of the remaining items unchanged.

SOLUTION:

      public static void removeItem(LinkedStackClass<Integer> intStack, Integer n) {_x000D_
         ..._x000D_

}

6. (Method: reverseStack) Task: Reverse a stack, using a queue. The original stack is lost. SOLUTION:

      public static void reverseStack(LinkedStackClass<Integer> s) {_x000D_
          QueueClass<Integer> q = new QueueClass<Integer>();_x000D_
          ..._x000D_

}7. (Method: reverseQueue) Task: Reverse a queue, using a stack. The original queue is lost.

SOLUTION:

       public static void reverseQueue(QueueClass<Integer> q){_x000D_
             LinkedStackClass<Integer> s = new LinkedStackClass<Integer>();_x000D_
             ..._x000D_

}8. (Method: printQueue) Task: Display the contents of a queue in direct order, leaving the queue

unchanged.

SOLUTION:

       public static void printQueue(QueueClass<Integer> q) {_x000D_
              ..._x000D_

}

SAMPLE OUTPUT:

Enter integers (999 to stop): 25 10 15 10 20 37 10 59 21 10 27 20 4 2 10 53 47 37 59_x000D_
77 27 20 10 999_x000D_
The original stack printed in direct order (bottom to top) is:_x000D_
25 10 15 10 20 37 10 59 21 10 27 20 4 2 10 53 47 37 59 77 27 20 10_x000D_
The stack printed in reverse order (top to bottom) is:_x000D_
10 20 27 77 59 37 47 53 10 2 4 20 27 10 21 59 10 37 20 10 15 10 25_x000D_
The stack stores 23 items._x000D_
The top is: 10_x000D_
The second item (below top) is: 20_x000D_
Enter value to be removed from stack: 10_x000D_
The stack after removing every occurrence of 10 is:_x000D_
25 15 20 37 59 21 27 20 4 2 53 47 37 59 77 27 20_x000D_
Reversed the stack. The new stack printed in direct order is:_x000D_
20 27 77 59 37 47 53 2 4 20 27 21 59 37 20 15 25_x000D_
The queue is:_x000D_
3 6 9 12 15 18 21 24 27 30_x000D_
The reversed queue is:_x000D_
30 27 24 21 18 15 12 9 6 3_x000D_

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.