![]() |
| ||
| Deleting Pointed node in Singly Linked List How to delete a node in a Singly Linked List using a pointer that points to the node? (Assume that you cannot traverse the list to find the previous node) -- With Regards Vishnu |
| ||
| Re: Deleting Pointed node in Singly Linked List This is a common test question. Have you tried to solve it yourself? Here's a hint: you can move data as well as change links. |
| ||
| Re: Deleting Pointed node in Singly Linked List Ya, I know u can shift up the links following the one pointed to. Or u can swap with the last node and delete the last node(If sorted order is not a criteria). But this is an optimisation problem. Consider this as an infinitely long link list. Both the above methods are not practical in such a scenario as both are computational intensive. Is there any other way?? |
| ||
| Re: Deleting Pointed node in Singly Linked List You only need to copy one data element and change one link. |
| ||
| Re: Deleting Pointed node in Singly Linked List [Edit: Post removed due to misinterpretation of the question. Assumed pre-check was possible] |
| ||
| Re: Deleting Pointed node in Singly Linked List >Ya, I know u can shift up the links following the one pointed to. Shift? It sounds like you're confused, but we'll proceed. >Or u can swap with the last node and delete the last node(If >sorted order is not a criteria). Sorted order is irrelevant since you're unlinking the node causing disorder anyway. And you don't need to swap unless you're returning the deleted node and need the data in the calling function. >Both the above methods are not practical in such a scenario >as both are computational intensive. Constant time performance with two operations is computationally intensive? The only way to improve that performance is to drop down to inline assembly and optimize the data movement with low level register tricks. Even then you won't see much of an improvement. You say you understand the solution I was suggesting, but you obviously don't if you think it's "computationally intensive". |
| ||
| Re: Deleting Pointed node in Singly Linked List Narue...your replyies seems to me like you are a very aggressive person. |
| ||
| Re: Deleting Pointed node in Singly Linked List i like agressive RrrRRraawwrrrrr..... |
| ||
| Re: Deleting Pointed node in Singly Linked List Narue is not so much agressive as frustrated with the lack of effort by many (especially younger) people in this world to even attempt to solve their own problems, an attitude I can very much relate to. But then we're both professionally employed in this profession and have to work with the end result of an educational cycle in which such lack of effort gets people degrees and diplomas which in turn get them hired to be our colleagues, saddling us with the burden of doing their work to get projects completed. |
| ||
| Re: Deleting Pointed node in Singly Linked List Quote:
Whilst it is entirely possible that these people can lead socially rewarding lives outside of work I find it difficult to imagine. A happy IT associated person, - are you kidding me? The constraints of life make this unlikely. :lol: |
| All times are GMT -4. The time now is 10:30 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC