Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part IV: Linked List Search (9 points): Assume I have a singly-linked list which

ID: 3593263 • Letter: P

Question

Part IV: Linked List Search (9 points): Assume I have a singly-linked list which contains a sentinel header/sentinel trailer,and a number of additional meaningful nodes/ The sentinel header has an elem value of -1 and the sentinel trailer has an elem value of 999. The meaningful nodes are not in any particular order. Write the Ct+ searchList function which will search for the node whose elem value is 300. If itis not found, stop at the sentinel trailer. The nodes were built using the following classes: class dataNode ( private: int elem; dataNode* next; friend class LinkedList; ) class LinkedList ( public: LinkedList): LinkedList() const int&searchList;() const; void addNode(int& e) private: dataNode head

Explanation / Answer

const int& LinkedList::searchList() const {
dataNode* cur = head->next;
int i = 0;
while(cur->elem != 999) {
if (cur->elem != 300) {
cur = cur->next;
i++;
}
return i;
}
return -1;
}

I can't show you sample output as you have not indicated other part of your code.