javascript
辛勤的搬砖者
这个作者很懒,什么都没留下…
展开
-
【数据结构连载一栈】【四则运算--后缀表达式】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 · 163 阅读 · 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 · 74 阅读 · 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 · 55 阅读 · 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 · 79 阅读 · 0 评论 -
【js】js基础练习题一
1、编写一个函数,实现数组去重 function deduplication(arr){ var s = []; for(var i=0;i<=arr.length-1;i++){ if(s.indexOf(arr[i]) == -1){ s.push(arr[i]) } } return s } var arr = [1,2,3,4,5,2,3,6,23,6,3,6,2,5] var l = deduplica原创 2020-06-01 23:16:31 · 468 阅读 · 0 评论 -
【数据结构连载一线性表】【双向链表】javascript
function Node() { this.data = null; this.next = null; this.pre = null; } function DoubleLinkedList() { this.length = 0; this.head = new Node(); this.tail = this.head; this.empty = function () { return this.tail === this原创 2021-05-08 16:21:39 · 62 阅读 · 0 评论 -
【数据结构连载一线性表】【单向循环链表】javascript
function Node() { this.data = null; this.next = null; } function CycleLinkedList() { this.length = 0; this.rear = new Node(); this.rear.next = this.rear; this.empty = function () { return this.rear === this.rear.next };原创 2021-05-07 16:53:53 · 52 阅读 · 0 评论 -
【数据结构连载一线性表】【单链表】javascript
function Node() { this.data = null; this.next = null; } function LinkedList() { this.length = 0; this.head = new Node(); this.tail = this.head; this.empty = function () { return this.length === 0 }; this.exist = fun原创 2021-05-07 16:51:52 · 45 阅读 · 0 评论 -
【数据结构连载一线性表】【顺序表】javascript
function List(maxSize) { this.maxSize = maxSize; this.length = 0; this.data = new Array(maxSize); this.empty = function () { // 顺序表是否为空 return this.length === 0; }; this.full = function () { // 顺序表是否已满原创 2021-05-07 16:46:54 · 58 阅读 · 0 评论 -
【数据结构连载一线性表】【双向循环链表】javascript
function Node() { this.data = null; this.next = null; this.pre = null; } function DoubleCycleLinkedList() { this.length = 0; this.head = new Node(); this.head.pre = this.head; this.head.next = this.head; this.tail = functio原创 2021-05-08 16:26:04 · 45 阅读 · 0 评论