Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

hI GUYS c++ trying to delete nodes with the given value. i write this code and compile perfectly, however, i do get a seg fault

image text in transcribed

hI GUYS

c++

trying to delete nodes with the given value. i write this code and compile perfectly, however, i do get a seg fault somehow. I couldnt think of any bugs in this code. Plese take a look and tell me whats wrong

btw lets say linkedlist is 3-3-2-3-null after i input the list and 3, the list should be 2-null;

void deleteNode Iteratively (LinkedListList, int value){ Node next: Node *p List->head; Node prev = NULL; while (List->head->data value) p = List->head->next ; delete List->head List->head = p; //if the head node has the same value, delete them and set a new head assert (List->head !=NULL) ; while (p.= NULL){ // start iterate if (p->data value) next = p->next ; delete p: p = next; if (p NULL) List->ta!! //reset tall = prev; else prev = p; // point to the previous node, incase of deleting the tail p->next

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago

Question

3. What information do participants need?

Answered: 1 week ago