Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions