preface

The concept is introduced

  • Queue: A linear table that allows insertion at one end and deletion at the other
  • A queue is a First In First Out linear table, or FIFO for short
  • The end of the queue that allows insertion is called the end of the queue, and the end of the queue that allows deletion is called the head
  • Queues can be stored in two ways
    • Sequential storage
    • Chain store
  • Two modes of operation for queues
    • The operation of entrance
    • The team operation

The principle of interpretation

We take [12 8 3 24 21] as an example to illustrate the implementation principle of sequential storage of queues

  • When nothing is done, the result is shown below

The operation of entrance

  • Queue entry inserts a random element 66 from the tail of the queue, which is 66. The effect is shown below.

The team operation

  • An out of queue operation removes element 12 from the head of the queue, while the head element is 8. The effect is shown below.

Time complexity

  • The time complexity of queuing and queuing operations is O(1).

Advantages and disadvantages of queues

  • Advantages:
    • Provide first-in, first-out storage
  • Disadvantages:
    • Everything else is slow to store

Results show

For more algorithm learning, please pay attention to my public number

instructions

  • In the public number to reply to the “algorithm source” to obtain the source code of ten classic algorithms
  • Reply “Algorithm books” in the public account to get the classic introduction algorithm books
  • Reply “data structure” in the public number to obtain data structure related source code