Question: Our goal is to find the first two equal consecutive strings in a linked list of string objects. Which of the following conditions is a

 Our goal is to find the first two equal consecutive stringsin a linked list of string objects. Which of the following conditions

Our goal is to find the first two equal consecutive strings in a linked list of string objects. Which of the following conditions is a correct replacement for the missing condition in the following while loop and results in the current reference referring to the first of two such nodes? LinkedNodecString > current = head; while (/*_CONDIIION_*) current = current. getNext(); If the list does not contain two consecutive nodes containing the same string, we will assume that it is ok for this code to throw an exception as a result. Methods from the LinkedNode class: - LinkedNode(T item, LinkedNodesT> next) // Constructs node combining item data with a reference to another node. - T getData()// Accesses the data reference within this node. - void setData(T item) //Mutates (changes) this node's data to be item. - LinkedNode getNext0 // Accesses the next reference within this node. - void setNext(LinkedNode n)// Mutates (changes) this node's next to be n. Link to the java api of the java.lang.String class . Hint: The example list ate. would terminate the loop when current was the LinkedNode containing the first instance of LinkedNodestring current - head; while( /-conorrion_\%) current = current, getNextO; If the list does not contain two consecutive nodes containing the same string, we will assume that it is ok for this code to throw an exception as a result. Methods from the LinkedNode class: - LinkedNode(T item, LinkedNodecT> next) // Constructs node combining item data with a reference to another node. - T getData0 // Accesses the data reference within this node. - void setData(T item) //Mutates (changes) this node's data to be item. - LinkedNodecT> getNext0 // Accesses the next reference within this node. - void setNext(LinkedNodecT> n) // Mutates (changes) this node's next to be n. Link to the java api of the java.lang. String class B. Hint: The example list would terminate the loop when current was the LinkedNode containing the first instance of current. getNextO. getData(). equals(current. getDato (O) Icurrent, getDataO) equals(current, getNext O, getData O ) current, charAt( ()= current, getNext(), charAt( ()

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!