Java record -51-stacks and queues

Source: Internet
Author: User

Stacks and queues stack and queue


Stacks (Stack):

The stack is also a special linear table, which is a last-in, first-out (LIFO) structure.

A stack is a linear table that restricts insert and delete operations only at the end of the table, and the footer is called the top of the stack, and the table header is called the bottom of the stack (bottom).

The physical storage of stacks can use sequential storage structures, or they can use chained storage structures.


Queuing (queue):

A queue is a linear table that restricts all inserts to be made only at one end of the table, while all deletions are made at the other end of the table.

The one end of the table that allows insertion is called the tail of the queue (Rear), and the one end that allows deletion is called the team header (Front).

The operation of the queue is performed on a first in, out (FIFO) basis.

The physical storage structure of a queue can be stored sequentially or chained to a storage structure.


Both the stack and the queue maintain a member variable that is used to store the stack or the elements in the queue. This member variable is typically implemented using LinkedList, and the stack or queue method is implemented based on the LinkedList method.

Java record -51-stacks and queues

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.