Extend the class linkedListType by adding the following operations: a.Write a fu
ID: 3626411 • Letter: E
Question
Extend the class linkedListType by adding the following operations:a.Write a function that returns the info of the kth element of the linked
list. If no such element exists, terminate the program.
Write a function that deletes the kth element of the linked list. If no such
element exists, tenninate the program.
b.Provide the definitions of these functions in the class linkedListType.
Also, write a program to test these functions. (Use either the class
unorderedLinkedList or the class orderedLinkedList to test your
function.)
Explanation / Answer
#include #include #include #include using namespace std; template class linkedListType : public list{ private: T data; public: bool operatorend()); } void del_firstmin() { T d = get_min(); linkedListType::iterator i; for (i = begin(); i != end(); i++) { if (*i == d) { this->erase(i); break; } } } void del_element(int iPos) { linkedListType::iterator i; int iCount = 0; for (i = begin(); i != end(); i++, iCount++) { if (iPos == iCount) { this->erase(i); break; } } if (iPos != iCount) { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.