TATA Consultancy Services Interview Question
SDE1sCountry: India
Interview Type: In-Person
linkedlist - this gives us the ease of needing to know only current node, no need to know the length of the queue nor the current node's position from the start.
array - this is good for storage complexity but will be more running complexity as implementation requires you to know the length of the array and current position from the start or the end of the array.
linked list gives us the advantage of not needing to maintain the context of length of the queue and current position. All we would need is pointer to current node we can write into.
- Suhas Manangi July 12, 2015Where as with array we need to know the length of the array to traverse the array in circular fashion else we will have buffer overflows. Array is always storage efficient but is running time heavy..