In C++
Implement the insertAtPosition function of the LinkedListclass.
bool LinkedList::insertAtPosition(int position, int d)
The job of this function is to insert a new node with given datad in the given position.
If position is less than 1 or greater than length + 1 then thefunction should leave the list unchanged and return false.
If given a legal position, the function will insert a new nodewith data d at that position and return true. For example, if thelist is initially { 1, 2, 3 } and we call insertAtPosition(2, 20)then the list will be changed to { 1, 20, 2, 3 }.
Expert Answer
An
PayPal Gateway not configured
PayPal Gateway not configured