4. Queue using LL #
Created Thursday 23 January 2020
As per the interface:
- We need to keep size
- For o(1) insertion, we always insert at the tail So a tail is required. Tail points to the last node in the queue.
- For o(1) deletion, we remove from head. So we need a head. Head points to the first node in the queue.
- front is also o(1) as we just need to print the head’s data, if it exists.
- There’s no need for being circular here. All operations are o(1), except print which is o(N) for both arrays and index.
- Hence it is established that basic stack and queues equally efficient in both their implementaions, arrays and LL.