Ask your own question, for FREE!
Computer Science 64 Online
OpenStudy (anonymous):

How do I implement this function in a sequence class with a linked list toolkit? // void remove_current( ) // Precondition: is_item returns true. // Postcondition: The current item has been removed from the sequence, and the // item after this (if there is one) is now the new current item.

OpenStudy (anonymous):

void sequence::remove_current () { if (is_item ==true) node *target_ptr; target_ptr=list_search(head_ptr, target); if (target_ptr == NULL) return false; target_ptr-> set_data(head_ptr-> data()); list_head_remove(head_ptr); --many nodes; return true; } } How do I fix my code above?

OpenStudy (rsmith6559):

To remove a node in a singly linked list you just need to change the target node predecessor's pointer from target node to target node's successor, keeping track of target node's address so that you can then delete it. This will put a bit of a crimp in how you search for the target node, because you'll also need it's predecessor. Draw it out on paper.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
SsTDOGRednek: What Element is I?
40 minutes ago 3 Replies 1 Medal
SsTDOGRednek: What is the compound I?
34 minutes ago 7 Replies 1 Medal
danielfootball123: HAPPY EASTER!!!!
6 hours ago 24 Replies 3 Medals
ShadowKid3: I drew Leon again (used suggestions from last art post) so Leon v2 :D
17 hours ago 4 Replies 0 Medals
Puck: for all you amazing people
24 minutes ago 4 Replies 2 Medals
Breathless: update on drawing.
20 hours ago 12 Replies 5 Medals
ShadowKid3: what are examples of a class three lever?
2 days ago 3 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!