当前位置:网站首页>Preliminary understanding of stack and queue
Preliminary understanding of stack and queue
2022-04-23 02:31:00 【Dead of night code】
One 、 The definition and characteristics of stack
1、 Definition : Stack (stack) It's a special linear table , It's limited at one end ( It's usually the tail of the table ) A linear table that performs insert and delete operations . Also known as Last in, first out The linear table , abbreviation LIFO structure .
2、 Stack related concepts :
① The stack is inserted only at the end of the table 、 Linear table of delete operations
② The end of the table is called the top of the stack Top, The header is called the bottom of the stack Base.
③ Insert the element to the top of the stack ( End of table ) The operation of , be called Push .
④ From the top of the stack ( End of table ) Operation to delete the last element , be called Out of the stack .
3、 Common applications of stack : Because stack operations have Last in, first out Inherent characteristics of , Make the stack a useful tool in programming . in addition , If the problem solving process has " Last in, first out ” If the natural characteristics of , Then the solution algorithm must also use " Stack ”. For example, the following questions may involve : Number conversion 、 Expression evaluation 、 The test of bracket matching 、 Eight queens question 、 Line editor 、 Function call 、 Maze solution 、 Implementation of recursive call .
4、 The basic operation of stack is shown in the figure below :

Two 、 The definition and characteristics of queues
1、 Definition : A queue is a special linear table , The insertion operation can only be performed at one end of the table , A linear table that performs a deletion operation at the other end of the table ( Cut the head and insert the tail ). Can only be calculated at the head and tail of the team , And access the node according to fifo (FIFO) Principles .
2、 Application of queues : Because the operation of the queue has fifo Characteristics of , Make queue become a useful tool to solve similar queuing problems in programming . The following is an example of queue application :
① Offline printout : Output in the order of application .
② In a multiuser system , Multiple users line up , Recycle in time CPU And main memory .
③ Queue up according to the priority of users , One queue per priority .
④ In real-time control system , The signal is processed in the order of reception .
⑤ Network message transmission , According to the order of arrival .
3、 Terms related to queues :① The tail of the watch is called the tail of the team , The header is called the head of the team .
② Inserting elements is called joining the team , Deleting an element is called dequeue .
③ The storage structure of queue is chain queue or sequential queue ( Commonly used cyclic order ).
4、 The common basic operations of queues are shown in the following figure :

3、 ... and 、 The linear table 、 Stack and queue comparison
1、 Stacks and queues are two commonly used 、 Important data structures , Stack and queue are restricted to insert and delete only in the table " Endpoint " On going The linear table . Therefore, it can be understood that both stack and queue are a special case of linear table .
2、 The following figure shows the comparison of the three :

版权声明
本文为[Dead of night code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220825058993.html
边栏推荐
- Startup of openstack service
- Fast and robust multi person 3D pose estimation from multiple views
- 想体验HomeKit智能家居?不如来看看这款智能生态
- Yes, from today on, our fans can participate in Netease data analysis training camp for free!
- 007_Redis_Jedis连接池
- Applet canvas canvas half ring
- After idea is successfully connected to H2 database, there are no sub files
- 002_ Redis_ Common operation commands of string type
- Leetcode39 combined sum
- 006_ redis_ Sortedset type
猜你喜欢

电源电路设计原来是这么回事

Yes, from today on, our fans can participate in Netease data analysis training camp for free!

Open3d point cloud processing

Global, exclusive, local Routing Guard

全局、独享、局部路由守卫

【无标题】

16、 Anomaly detection
![Handwritten memory pool and principle code analysis [C language]](/img/9e/fdddaa628347355b9bcf9780779fa4.png)
Handwritten memory pool and principle code analysis [C language]

SQL server2019无法下载所需文件,这可能表示安装程序的版本不再受支持,怎么办了

Latin goat (20204-2022) - daily question 1
随机推荐
【2019-CVPR-3D人体姿态估计】Fast and Robust Multi-Person 3D Pose Estimation from Multiple Views
Dynamic batch processing and static batch processing of unity
C语言中*与&的用法与区别 以及关键字static和volatile 的含义
Common formatting problems after word writing
012_ Access denied for user ‘root‘@‘localhost‘ (using password: YES)
Log4j2 configuration
On LAN
Yes, from today on, our fans can participate in Netease data analysis training camp for free!
WordPress calls the specified page content. 2 get_ children()
Target narak
hack the box optimum靶机
Explain JS prototype and prototype chain in detail
MySQL C language connection
002_Redis_String类型常见的操作命令
全局、独享、局部路由守卫
PTA: 点赞狂魔
[suggestion collection] hematemesis sorting out golang interview dry goods 21 questions - hanging interviewer-1
010_StringRedisTemplate
Network jitter tool clumsy
go语言打怪通关之 ⌈互斥锁和状态协程⌋