Let x be a node in SLL. Write a C++ function to delete the data in this node. Following this deletion, the number of nodes in the list is one less than before the deletion. Your function must run for O(1).
Bharath_4
0
Newbie Poster
Recommended Answers
Jump to PostDone. Show me your solution and I'll show you mine.
Jump to PostBut you won't learn anything by being given the answer. The trick is to think outside the box a little bit. Naively deleting a node from a single linked list is O(n) because you have to find the previous node for unlinking. So what can you do to avoid needing …
Jump to PostDid you figure it out? As mentioned before, I really am trying to help, but without flat out giving you the answer.
All 11 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Bharath_4
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Bharath_4
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Bharath_4
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Bharath_4
0
Newbie Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Bharath_4
0
Newbie Poster
happygeek
2,411
Most Valuable Poster
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.