Stack vs queue

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.