logo

Crowdly

Browser

Додати до Chrome

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на online.upr.edu?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome