Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My issue: Exception Error: Access violation reading location 0xDDDDDDDD I am wanting to program a function that will remove an element from a sorted doubly

My issue: Exception Error: Access violation reading location 0xDDDDDDDD

I am wanting to program a function that will remove an element from a sorted doubly link list in recursion. My function below works if I remove any element beside the head of the list. When I try to remove the head, it gives me an exception error. It gives me an exception error because I remove the head of the list which I lose the access to the head of the list but I am sure how to modify my program so that I doesn't lose the head of my list even after removing the head of my list. Program is in c++

Any help would be appreciated

Code:

DNode* DoublyLinkedList::removeFromSortedRec(DNode* head, int target){

if (head == nullptr)

{

return nullptr;

}

else if (target == head->data)

{

DNode* current = head;

DNode* nextNode = head->next;

delete current; //Error occurs

return nextNode;

}

DNode* nextNode = removeFromSortedRec(head->next, target);

head->next = nextNode;

if (nextNode)

{

nextNode->prev = head;

}

return head;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+How many children do you have?

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago