
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;
Hi friend, You have not posted whole class structure.
PLease find my implementation.
public T dequeue(int x) throws EmptyCollectionException, InvalidArgumentException {
if(numNodes == 0)
throw new EmptyCollectionException();
if( x > 4 || x > numNodes) {
throw new InvalidArgumentException();
}
LinearNode<T> t = null;
if(x == 0){
t = front;
if(numNodes == 1)
back = null;
numNodes = 0;
front = front.getNext();
}else if(x == numNodes-1){
t = back;
back = frontFive.get(x-1);
frontFive.get(x-1).setNext(null);
numNodes--;
}
return t;
}
I just need a java mehod that follows the Javadocs Implented using an arraylist. public class...
------------------------------------------------------------------------------------------------------------
CODE ALREADY HAVE
BELOW---------------------------------------------------------------------------------------
public class LinkedQueue<T> implements
QueueADT<T>
{
private int count;
private LinearNode<T> head;
private LinearNode<T> tail;
public LinkedQueue()
{
count = 0;
head = null;
tail = null;
}
@Override
public void enqueue(T element)
{
LinearNode<T> node = new
LinearNode<T> (element);
if(isEmpty())
head =
node;
else
...
There is a data structure called a drop-out stack that behaves like a stack in every respect except that if the stack size is n, then when the n+1element is pushed, the bottom element is lost. Implement a drop-out stack using links, by modifying the LinkedStack code. (size, n, is provided by the constructor. Request: Please create a separate driver class, in a different file, that tests on different types of entries and show result of the tests done on...
Complete the implementation of the LinkedStack class presented in Chapter 13. Specifically, complete the implementations of the peek, isEmpty, size, and toString methods. See Base_A06Q1.java for a starting place and a description of these methods. Here is the base given: /** * Write a description of the program here. * * @author Lewis et al., (your name) * @version (program version) */ import java.util.Iterator; public class Base_A06Q1 { /** * Program entry point for stack testing. * @param args Argument...
Please help with my car traffic simulator!
Code that I already have below, I do not know how to start it
off!
public class IntersectionSimulation
{
private final static int EAST_WEST_GREEN_TIME = 30 ;
private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ;
private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ;
private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ;
private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...
In Java. What would the methods of this class look like?
StackADT.java
public interface StackADT<T>
{
/** Adds one element to the top of this stack.
* @param element element to be pushed onto stack
*/
public void push (T element);
/** Removes and returns the top element from this stack.
* @return T element removed from the top of the stack
*/
public T pop();
/** Returns without removing the top element of this
stack.
* @return T...
public class CharNode{ private CharNode link; private char info; public CharNode(char info) { this.info = info; this.link = null; } public CharNode(char c, CharNode link) { this.info = info; this.link = link; } public CharNode getLink() { return link; } public void setLink(CharNode link) { this.link = link; } public char getInfo() { return info; } public void setInfo(char info) { this.info = info; } } //Remember Queue is a first-in-first-out data structure public class CharQueue { // front is...
In addition to the base files, three additional files are attached: EmptyCollectionException.java, LinearNode.java, and StackADT.java. These files will need to be added to your Java project. They provide data structure functionality that you will build over. It is suggested that you test if these files have been properly added to your project by confirming that Base_A05Q1.java compiles correctly. Complete the implementation of the ArrayStack class. Specifically, complete the implementations of the isEmpty, size, and toString methods. See Base_A05Q1.java for a...
Java help: Please help complete the locate method that is in bold.. public class LinkedDoubleEndedList implements DoubleEndedList { private Node front; // first node in list private Node rear; // last node in list private int size; // number of elements in list ////////////////////////////////////////////////// // YOU MUST IMPLEMENT THE LOCATE METHOD BELOW // ////////////////////////////////////////////////// /** * Returns the position of the node containing the given value, where * the front node is at position zero and the rear node is...
Write a Client class with a main method that tests the data structures as follows: For the ArrayStack, LinkedStack, ArrayQueue and LinkedQueue: Perform a timing test for each of these data structures. Each timing test should measure in nanoseconds how long it takes to add N Integers to the structure and how long it takes to remove N Integers from the structure. N should vary from 10 to 100,000,000 increasing N by a factor of 10 for each test. Depending...
I was told I need three seperate files for these classes is there anyway to tie all these programs together into one program after doing that. I'm using netbeans btw. import java.util.ArrayList; import java.util.Scanner; /** * * */ public class MySorts { public static void main(String[] args) { Scanner input = new Scanner(System.in); String sentence; String again; do { System.out .println("Enter a sentence, I will tell you if it is a palindrome: ");...