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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!