Create a Java code that includes all the methods from the Lecture slides following the ADTs
LECTURE SLIDES
1.Queue ADT using linked list internally:
// Implementation of queue using linked list internally
// Noade class
class QNode
{
int data;
QNode nextNode;
// constructor to create a new linked list node
public QNode(int data) {
this.data = data;
this.nextNode = null;
}
}
// A class to represent a queue
//The queue, front stores the front node and rear stores the last
node of LL
class Queue
{
QNode front, rear;
public Queue() {
this.front = this.rear =
null;
}
// Method to add an data to the queue.
void enqueue(int data)
{
// Create a new LL node
QNode temp = new QNode(data);
// If queue is empty, then new node
is front and rear both
if (this.rear == null)
{
this.front = this.rear =
temp;
return;
}
// Add the new node at the end of
queue and change rear
this.rear.nextNode = temp;
this.rear = temp;
}
// Method to remove an data from queue.
QNode dequeue()
{
// If queue is empty, return
NULL.
if (this.front == null)
return null;
// Store previous front and move
front one node ahead
QNode temp = this.front;
this.front =
this.front.nextNode;
// If front becomes NULL, then
change rear also as NULL
if (this.front == null)
this.rear = null;
return temp;
}
}
public class Example
{
public static void main(String[] args)
{
Queue q=new Queue();
q.enqueue(1);
q.enqueue(2);
q.dequeue();
q.dequeue();
q.enqueue(3);
q.enqueue(4);
q.enqueue(5);
System.out.println("Dequeued item
is "+ q.dequeue().data);
}
}
Create a Java code that includes all the methods from the Lecture slides following the ADTs...
Create a Java code that includes all the methods from the Lecture slides following the ADTs LECTURE SLIDE Collect/finish the Java code (interface and the complete working classes) from lecture slides for the following ADTS 2) ArrayList ADT that uses a linked list internally (call it LArrayList) Make sure you keep the same method names as in the slides (automatic testing will be performed)! For each method you develop, add comments and estimate the big-O running time of its algorithm....
Collect/finish the Java code (interface and the complete working classes) from lecture slides for the for the following ADT: 3) Queue ADT that uses an array internally (call it AQueue) Make sure you keep the same method names as in the slides (automatic testing will be performed)! Make sure your classes implement the corresponding interfaces. Put your classes in a package called cse11. Try to make the code robust and try to use generics. The Queue ADT The Queue ADT...
create a class named IntegerQueue given a singlylinkedqueue of integers, write the following methods: max(SinglyLinkedQueue<Integer> s) to return the max element in the queu. min(SinglyLinkedQueue<Integer> s) to return the min element in the queue. sum(SinglyLInkedQueue<Integer> s) to return the sum of elements in the queu. median(SinglyLinkedQueue<Integer> s) to return the median of elements in the queue. split(SinglyLinkedQueue<Integer> s) to separate the SinglyLinkedQueue into two ArrayQueues based on whether the element values are even or odd. package Stack_and_Queue; import java.util.Iterator; import...
Plz help me with the code. And here are the requirement. Thanks!! You are required to design and implement a circular list using provided class and interface. Please filling the blank in CircularList.java. This circular list has a tail node which points to the end of the list and a number indicating how many elements in the list. And fill out the blank of the code below. public class CircularList<T> implements ListInterface<T> { protected CLNode<T> tail; // tail node that...
NO ONE HAS PROVIDED THE CORRECT CODE TO PROVIDE THE GIVEN OUTPUT. PLEASE PROVIDE CODE THAT WOULD CAUSE THE HW1.java TO PRINT THE RIGHT DATA.!!! The LinkedList class implements both the List interface and the Stack interface, but several methods (listed below) are missing bodies. Write the code so it works correctly. You should submit one file, LinkedList.java. Do not change the interfaces. Do not change the public method headers. Do not rename the LinkedList class. None of your methods...
How do I pass values to this function? class DynIntQueue { struct QueueNode { int value; QueueNode *next; QueueNode(int value1, QueueNode *next1 = nullptr) { value = value1; next = next1; } }; // These track the front and rear of the queue QueueNode *front; QueueNode *rear; public: // Constructor and Destructor DynIntQueue(); ~DynIntQueue(); // Member functions void enqueue(int); void dequeue(int &); bool isEmpty() const; void clear(); }; main #include <iostream> #include "DynIntQueue.h" using namespace std; int main() {DynIntQueue list;...
Java/Queues ** Task: Write a JUnit test that shows a failure in some part of the ADT -----ArrayQueue.java------- public class ArrayQueue { private static final int INITIAL_CAPACITY = 2; // to permit easier testing private Object[] contents; private int front, rear; /** * Create an empty queue with an initial capacity. */ public ArrayQueue() { contents = new Object[INITIAL_CAPACITY]; } /** * Add an element to...
QUESTION 1: Queue Class: Write a Queue class using doubly-linked structure and implement the following functionalities. enqueue (inserts element to the end) dequeue (removes the front element and provides content) isEmpty (checks whether the Queue is empty or not) makeEmpty () peek (provides the element sitting at the top/front, but does not remove) print (prints all the elements from front to the end) reversePrint(prints all the elements from end to the front with the help of back pointers inside your...
In java Build a QueueInt class for integers that is compatible with the driver code below. The QueueInt should operate in a FIFO (first in, first out) fashion and implement the variables and methods also listed below: Data Members: Declare and initialize, as needed, the data item(s) you will need to manage a queue of integers. You may only use arrays and primitives for your instance and/or static variables (I,e You can’t use Java defined Queue / Stack / List...
I just need a java mehod that follows the Javadocs Implented using an arraylist. public class WorkAheadQueue<T> implements WorkAheadQueueADT<T> { private LinearNode<T> front; private LinearNode<T> back; private int numNodes; private ArrayList<LinearNode<T>> frontFive; Removes and returns the element that is at place x in the queue. Precondition: x must be less than 5, x must be less than size * Note: indexing from 0: 0-front element, I =-second element, etc. eparam x the passed in index of...