Question: Part 1: Creating a Queue 1. Create a Node class containing two variables Int data; Node Next; 2. Create a queue class containing: Node head=null;
Part 1: Creating a Queue
1. Create a Node class containing two variables
Int data;
Node Next;
2. Create a queue class containing:
Node head=null;
Node tail=null;
int size=0;
3. Try to implement the flowing methods:
public void add(int element)
public int poll()
public int peek()
public Boolean isEmpty()
public void print()
4. Create main class to test the created methods
Part 2: creating a stack
1.Create a Node class containing two variables
int data;
Node prev;
2.Create a queue class containing:
Node head=null;
int size=0;
3.Try to implement the flowing methods:
public void push(int elemnt)
public int pop()
public int peek()
public Boolean isEmpty()
public void print()
4.Create main class to test the created methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
