Amazon Interview Question
Software Engineer / DevelopersTeam: Kindle-Periodicals
Country: India
Interview Type: In-Person
We can delete at position "i" in O(1) time...
ptr = head + (i-1)*sizeof(node);
now delete ptr->next node....
have to do some error checking also
Using link list while keeping one pointer at tail
- NaiveCoder March 18, 2012InsertAtTail and GetTail will be in O(1)
While DeleteNodeAtPosition will take O(n) time in worse case.
The benefit of using link list over array is to get dynamic size