All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Algorithms
Linked List Deleted (Posted on 2021-05-31) Difficulty: 3 of 5
You are given a pointer to the middle node of a singly linked list. Delete that node.

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution Comment 1 of 1
Each node of a singly linked list contains, in addition to the information concerning its subject matter, a pointer to the next node on the list. 

Use the pointer you already have to retrieve the pointer on the node that's to be deleted. You will use that pointer twice: the first time to copy that next node into the memory occupied by the node to be deleted; the second time to free up the memory previously occupied by that node that you moved away to take the place occupied by the deleted node.

  Posted by Charlie on 2021-05-31 09:20:21
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (8)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information