a linked list is given, and a only pointer to a node is given which need to be deleted. it is singly linked list. you dnt have accees to any other pointer like head or what. you only have that node pointer in ur hand. thanks.
nitin1
15
Master Poster
Recommended Answers
Jump to PostSwap the data with the next node and then delete that node. This trick is obviously incomplete and its suitability depends on the design of the list, but if you're working with unreasonable requirements, you often have no choice but to enforce unreasonable limitations on the solution.
Jump to PostYou say "a linked list is given", and a "pointer to a node which is to be deleted". Do you actually mean this; that you get the list in some way, AND the node to be deleted?
If you have nothing but the node to be deleted, and it's the …
Jump to Postbut problem arises when the node given to us is last node in the linked list. then ?
That falls under my "you often have no choice but to enforce unreasonable limitations" clause. If your list doesn't have a sentinel tail node, you're SOL. Too bad, so sad, …
All 12 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
Moschops
683
Practically a Master Poster
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.