Algorithms and Data Structures

computer science

Description

Generic Stack and Queue Implementations 

 Create a new java class called ListNode. Implement ListNode as a generic version ofIntNode.public class ListNode {}
 Create a generic class called Queue, which is a linked list implementation of a queue data type. The queue must have the following methods: 
 public void enqueues (T value){}This method should add a new node to the back of the queue. 
 public T dequeue(){}This method should remove a node from the front of the queue and return its value
  public T peek(){}This method should return the value of the front node without removing it from the queue
 Create a new generic class called Stack, which is a linked list implementation of a stack data type. The stack must have the following methods: 
 public void push(T value){}This method should add a new node to the top of the stack. 
 public T pop(){}This method should remove a node from the top of the stack and return its integer value 
 public T peek(){}This method should return the integer value of the top node without removing it from the stack
 Test your implementation by creating a list of integers and a list of Strings using the generic stack and Queue classes.


Instruction Files

Related Questions in computer science category


Disclaimer
The ready solutions purchased from Library are already used solutions. Please do not submit them directly as it may lead to plagiarism. Once paid, the solution file download link will be sent to your provided email. Please either use them for learning purpose or re-write them in your own language. In case if you haven't get the email, do let us know via chat support.