
栈
数据结构---栈
辛勤的搬砖者
这个作者很懒,什么都没留下…
展开
-
【数据结构连载一栈】【四则运算--后缀表达式】python
class Node(object): def __init__(self, data=None): self.data = data self.next = None def __str__(self): return "数据:{data},地址:{next}".format(data=self.data, next=id(self.next))class LinkedStack(object): def __init__(.原创 2021-05-14 16:43:45 · 302 阅读 · 0 评论 -
【数据结构连载一栈】【四则运算--后缀表达式】javascript
function Node(value) { this.data = value; this.next = null;}function LinkedStack() { this.head = null; this._length = 0; this.clear = function () { this.head = null; this._length = 0; }; this.empty = function原创 2021-05-14 16:42:53 · 217 阅读 · 0 评论 -
【数据结构连载一栈】【四则运算--后缀表达式】golang
package mainimport ( "fmt" "strconv" "strings")type Node struct { data interface{} next *Node}type LinkedStack struct { length int head *Node}func NewLinkedStack() LinkedStack { return LinkedStack{length: 0, head: nil}}func (s *Linke原创 2021-05-14 16:42:00 · 317 阅读 · 0 评论 -
【数据结构连载一栈】【斐波那契数列】golang
package mainimport "fmt"// FibonacciFor 循环func FibonacciFor(num int) []int { a := 0 b := 1 l := make([]int, 0) for i := 0; i < num; i++ { l = append(l, a) tmp := a a = b b = tmp + a } return l}// FibonacciRecursive 递归func fibonacc原创 2021-05-14 16:40:16 · 131 阅读 · 0 评论 -
【数据结构连载一栈】【斐波那契数列】javascript
// 循环function fibonacci_for(num) { let l = []; let a = 0; let b = 1; for (let i = 0; i < num; i++) { l.push(a); const tmp = a; a = b; b = tmp + b; } return l;}// 递归function fibonacci_recursive原创 2021-05-14 16:39:36 · 110 阅读 · 0 评论 -
【数据结构连载一栈】【斐波那契数列】python
# 循环def fibonacci_for(num): a, b = 0, 1 l = [] for i in range(num): l.append(a) a, b = b, a + b return l# 递归def fibonacci_recursive(num): l = [] def fibonacci(num): if num == 0: return 0 .原创 2021-05-14 16:38:48 · 139 阅读 · 0 评论 -
【数据结构连载一栈】【链式存储栈】golang
package mainimport "fmt"type Node struct { data interface{} next *Node}type LinkedStack struct { length int head *Node}func NewLinkedStack() LinkedStack { return LinkedStack{length: 0, head: nil}}func (s *LinkedStack) Clear() { s.length原创 2021-05-14 16:37:10 · 95 阅读 · 0 评论 -
【数据结构连载一栈】【链式存储栈】javascript
function Node(value) { this.data = value; this.next = null;}function LinkedStack() { this.head = null; this._length = 0; this.clear = function () { this.head = null; this._length = 0; }; this.empty = function原创 2021-05-14 16:36:26 · 89 阅读 · 0 评论 -
【数据结构连载一栈】【链式存储栈】python
class Node(object): def __init__(self, data=None): self.data = data self.next = None def __str__(self): return "数据:{data},地址:{next}".format(data=self.data, next=id(self.next))class LinkedStack(object): def __init__(s原创 2021-05-14 16:35:39 · 102 阅读 · 0 评论 -
【数据结构连载一栈】【顺序存储栈】python
# -*- coding: UTF-8 -*-class ListStack(object): def __init__(self, max_size): self._max_size = max_size self._stack = [None] * self._max_size self._top = -1 self._length = 0 def clear(self): self._stack =原创 2021-05-08 16:43:02 · 92 阅读 · 0 评论 -
【数据结构连载一栈】【顺序存储栈】golang
package mainimport "fmt"type ListStack struct { top int stack []interface{} length int maxSize int}func NewListStack(maxSize int) ListStack { return ListStack{ top: -1, stack: make([]interface{}, maxSize), length: 0, maxSi原创 2021-05-08 16:42:24 · 133 阅读 · 0 评论 -
【数据结构连载一栈】【顺序存储栈】javascript
function ListStack(maxSize) { this.maxSize = maxSize; this.stack = new Array(maxSize); this.top = -1; this._length = 0; this.clear = function () { this.stack = new Array(maxSize); this.top = -1; this._length = 0;原创 2021-05-08 16:41:39 · 110 阅读 · 0 评论