Python常见数据结构-栈
来源:互联网 发布:sql server许可模式 编辑:程序博客网 时间:2024/05/06 09:31
Python常见数据结构-栈
首先,栈是一种数据结构。具有后进先出特性。
#栈的实现class Stack(): def __init__(self,size): self.stack=[] self.size=size self.top=-1 def push(self,content): if self.Full(): print "Stack is Full" else: self.stack.append(content) self.top=self.top+1 def out(self): if self.Empty(): print "Stack is Empty" else: self.top-=1 def Full(self): if self.top==self.size-1: return True else: return False def Empty(self): if self.top==-1: print "Stack is Empty"if __name__=="__main__": q=Stack(7) q.Empty() q.push("hello") q.Empty()
阅读全文
0 0
- Python常见数据结构-栈
- python 中的常见数据结构
- Python常见数据结构详解
- python常见数据结构
- Python常见数据结构整理
- Python常见数据结构整理
- Python常见数据结构详解
- Python常见数据结构整理
- Python常见数据结构详解
- PYTHON常见数据结构整理
- Python常见数据结构-队列
- Python中常见的数据结构
- 常见数据结构与算法的 Python 实现
- python学习(一)常见的数据结构
- 数据结构之栈常见案例
- 常见数据结构
- Python中使用list来模拟常见的数据结构
- Python数据结构—-栈
- 解决$.ajax()在IE10以下失效的问题
- Nginx+keepalived 实现负载均衡,高可用
- RabbitMQ(三)消息确认机制(事务+Confirm)
- in-scroll
- 开发动态的Inventory数据源
- Python常见数据结构-栈
- 正则表达式提取项目中所有带IP的网址
- OpenGL从1.0开始--OpenGL显示表(下)
- LeetCode 307 Range Sum Query
- 关于对lazyload的原理进行的学习
- 责任链模式
- 公路村村通
- SecureCRT 颜色方案
- 快速检索(二)之ListView的使用进行数据填充及点击事件