logo

Crowdly

Browser

Add to Chrome

Engineer Sophia is working on implementing the following code for her enqueue() ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Engineer Sophia is working on implementing the following code for her enqueue() method on a DoublyLinkedQueue<E> where the front of the queue can be accessed via header.getNext(). There is a bug in her code that causes an assertion error every time she tries to test it with a unit test. The implementation is as follows:

@Override

public void enqueue(E e){

    if(e == null) 

        throw new IllegalArgumentException("Parameter cannot be null");

    Node<E> nextNode = trailer;

    Node<E> prevNode = trailer.getPrev();

    Node<E> newNode = new Node(e, nextNode, prevNode);

    prevNode.setNext(newNode);

    nextNode = newNode;

    currentSize++;

}

Choose the answer that fixes said bug:

0%
0%
0%
0%
0%
More questions like this

Want instant access to all verified answers on online.upr.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome