[email protected] * * * * * *...">

当前位置:网站首页>Stack and queue

Stack and queue

2022-07-06 03:57:00 Pupu pupu

Author: intellectuals
Computer science
Controllable things Heavy and calm Uncontrollable things Optimistic face
[email protected]

️ ️ ️
————————————————
Copyright notice : This paper is about CSDN Blogger 「 Pu Shangqing sky 」 The original article of


Knowledge point
Stack and queue Are a special linear structure , Just for Insert / Delete The way of elements is limited

  • Stack : First in, then out (push/pop/peek The time complexity of O(1))
  • queue : fifo (add/remove/element The time complexity of O(1))
     Insert picture description here

queue

  • queue : Advanced display (FIFO)
  • There are two interfaces :
    1.Queue: queue
    2.Deque: The bidirectional queue
     Insert picture description here

Queue Common methods of queue

add: Specify that the element is inserted into the queue
element: Retrieve but not delete , The head of its queue
remove: Retrieve and delete , The head of this queue
peek: Retrieve but not delete , The head of the queue
poll: Retrieve and delete , The head of this queue

Deque The bidirectional queue

 Insert picture description here

Stack

  • Stack : First in, then out

Common methods

Stack class :Stack
Method :
empty: Judge whether the stack is empty
push: Add elements at the top of the stack
peek: Look at the top of the stack elements , But don't delete
pop: Delete stack top element , And return the element

Praise first and then watch , Develop habits !!!^ _ ^
Update your knowledge every day !!!
It's not easy to code words , Everyone's support is my driving force to stick to it . Don't forget after you like Focus on I oh !

原网站

版权声明
本文为[Pupu pupu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202132255176893.html