[algogeeks] Re: [Linkedlist] Given only a pointer to a node to be deleted in a singly linked list how you handle deleting last node

2012-07-11 Thread Mr.B
Even if assuming the allocation is uniform. Knowing the address of previous node is the limitation on SLL in constant time. Also, if we know the address of previous node. we are done. But, finding it will take O(n) time. On Wednesday, 11 July 2012 03:36:46 UTC-4, invictus wrote: > > Well, we can

[algogeeks] Re: [Linkedlist] Given only a pointer to a node to be deleted in a singly linked list how you handle deleting last node

2012-07-11 Thread invictus
Well, we can do one thing but it might not work in all cases. First of all you need to know the node structure. Assume it has an int and a next pointer. Assumption - Memory allocation for nodes did not happened at random location but uniformly. 1. Find out the memory address contained in the n

[algogeeks] Re: [Linkedlist] Given only a pointer to a node to be deleted in a singly linked list how you handle deleting last node

2012-07-09 Thread Mr.B
The constant time removal of last node in a SLL is the limitation of approach you have in mind. -- I read it in somewhere (may be Cracking Coding interview 4th edition) if we have access to head.. then.. its the trivial O(n) time. On Monday, 9 July 2012 16:06:17 UTC-4, subharansu wrote: > > Is t