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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started