preface
A new series, “Easy to Understand Data Structures and Algorithms by Looking at Pictures”, is launched, mainly using pictures to describe common data structures and algorithms, easy to read and understand. This series includes dozens of examples of heaps, queues, lists, trees, graphs, sorts, and more.
The queue
A queue is a restricted linear table through which the elements stored are sequential. Its insert operations are only allowed at the back end of the table, and its delete operations are only allowed at the front end of the table. The end that inserts is called the end of the queue, and the end that deletes is called the head.
The data In the queue comes In and Out of the queue In a First In First Out (FIFO) manner.
Implementation of queues
Queues can be implemented in many ways, mainly by using different structures to store queue elements, such as arrays, one-way linked lists, two-way lists, etc. Here’s the implementation of the array approach.
The four elements of the implementation are the array, the head pointer, the tail pointer, and the set of queue operations. The array is used to store elements, the head pointer is used to guide the head position of the team, the tail pointer is used to guide the tail position of the team, and the core operations of the queue are in and out of the queue. In addition, the number of elements stored in the queue cannot exceed the length of the array.
enqueue
Add “the”,”monster”,”is” and “coming” to the queue respectively.
dequeue
Perform two dequeueing operations on the queue,
————- Recommended reading ————
Summary of my open Source projects (Machine & Deep Learning, NLP, Network IO, AIML, mysql protocol, Chatbot)
Why to write “Analysis of Tomcat Kernel Design”
2018 summary data structure algorithms
2018 Summary machine learning
2018 Summary Java in Depth
2018 Summary of natural language processing
2018 Summary of deep learning
2018 summary JDK source code
2018 Summary Java concurrency Core
2018 summary reading passage
Talk to me, ask me questions:
Welcome to: