Question: JAVA; Solve for //ToDo public class MyDeque { Node first = null; Node last = null; int N = 0; static class Node { public

JAVA; Solve for "//ToDo"

public class MyDeque { Node first = null; Node last = null; int N = 0;

static class Node { public Node() { } public double item; public Node next; public Node prev; }

public MyDeque () { }; public boolean isEmpty () { return N == 0; } public int size () { return N; }

public void pushLeft (double item) { // TODO }

public void pushRight (double item) { // TODO }

public double popLeft () { if (N == 0) throw new NoSuchElementException (); return StdRandom.uniform (); // TODO }

public double popRight () { if (N == 0) throw new NoSuchElementException (); return StdRandom.uniform (); // TODO }

/* The concat method should take the Nodes from "that" and add them to "this" * After execution, "that" should be empty. * See the tests in the main program. * * Do not use a loop or a recursive definition. * This method can declare Node variables, but may not create new node objects (using "new"). * Therefore the method should not call pushLeft or pushRight (which use create new objects). */ public void concat (MyDeque that) { // TODO }

/* Delete should delete and return the kth element from the left (where k is between 0 and N-1). * See the tests in the main program. * * You may use a loop or a recursive definition here. * This method can declare Node variables, but may not create new node objects (using "new"). * Therefore the method should not call pushLeft or pushRight (which use create new objects). */ public double delete (int k) { if (k < 0 || k >= N) throw new IllegalArgumentException (); return StdRandom.uniform (); // TODO }

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!