Linkstack. Java
Linkqueue. Java
The program emphasizes that stacks and queues are conceptual entities independent of their specific implementations.
Stack implementation using arrays or linked lists is the same.
The importance of stack lies in its push () and POP () operations. And how to use them, rather than implementing the internal mechanism of these operations.
When should I use a linked list instead of an array to implement a stack or queue?
It depends on whether the stack or queue can accurately predict the amount of data to be accommodated.
If this is not clear, the linked list shows better adaptability than the array.
Both of them are fast, so the speed is not the focus of consideration.
Linked List vs Array
If you need to access element N immediately, it is not good to use the linked list, because for the linked list
Random Access is not an efficient operation.
Arrays are good at random access.
Stack vs queue