The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Please solve the attached problem. Â It's from previous semester. Â It would be great if you provide explanation along with answer coding. Â
Â
Problem 3Consider the following class that implements a doubly-linked list of integers with no dummy node.Thelast node’snextpointer is NULL; the Frst node’sprevpointer is NULL.There is no tail pointer.When thelist is empty,headis NULL.class LinkedList{public:…int countAdjacentMatches () const;void eraseLast (){if (head != NULL)eraseLastAux (head);}void writeDi± (const LinkedList& other) const{wd (head, other.head);}private:struct Node{int value;Node* next;Node* prev;};Node* head;void eraseLastAux (Node* h);void wd (const Node* p1, const Node* p2) const;};a.ThecountAdjacentMatchesmember func²on counts how many nodes have a value that is equalto the value of the node that immediately follows it in the list.³or examples, if the LinkedListacontained nodes with the values 3 6 6 17 4 4 4 8 4 7, then the calla.countAdjacentMatches()returns 3, because it counted the Frst 6 and the Frst two 4s.Write thecountAdjacentMatches()member func²on no more than 15 lines long.int LinkedList::countAdjacentMatches() const{no more than 15 lines}
Attachments: