当前位置:网站首页>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
边栏推荐
- Leetcode39 combined sum
- Global, exclusive, local Routing Guard
- Deploying sbert model based on torchserve < semantic similarity task >
- 假如404页面是这样的 | 每日趣闻
- 89 logistic回歸用戶畫像用戶響應度預測
- 基于Torchserve部署SBERT模型<语义相似度任务>
- 全局、独享、局部路由守卫
- tp6阿里云短信 window 报 cURL error 60: SSL certificate problem: unable to get local issuer certificate
- 高效音乐格式转换工具Music Converter Pro
- day18--栈队列
猜你喜欢
Rich intelligent auxiliary functions and exposure of Sihao X6 security configuration: it will be pre sold on April 23
The usage and difference of * and & in C language and the meaning of keywords static and volatile
高效音乐格式转换工具Music Converter Pro
Leetcode40 - total number of combinations II
RT_Thread自问自答
hack the box optimum靶机
Network jitter tool clumsy
JVM类加载器
定了,今日起,本号粉丝可免费参与网易数据分析培训营!
假如404页面是这样的 | 每日趣闻
随机推荐
JVM类加载器
Multithreading technology core
Understanding process (multithreading primary)
Open3d point cloud processing
LeetCode 349. Intersection of two arrays (simple, array) Day12
New book recommendation - IPv6 technology and application (Ruijie version)
智能辅助功能丰富,思皓X6安全配置曝光:将于4月23日预售
想用Mac学习sql,主要给自己个充足理由买Mac听听意见
Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools
JVM运行时数据区(一)
Fast and robust multi person 3D pose estimation from multiple views
Startup of openstack service
Usage of vector common interface
011_ Redistemplate operation hash
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
Kubernetes cluster installation based on Kirin SP10 server version
Global, exclusive and local routing guard
006_redis_SortedSet类型
001_ Redis set survival time
电源电路设计原来是这么回事