摘要: function BinarySearchTree() { this.root = null; this.count = 0; // 内部类 存放节点的信息 function Node(key) { this.key = key; this.left = null; this.right = nul 阅读全文
posted @ 2021-06-01 15:01 正经的流刺源 阅读(64) 评论(0) 推荐(0) 编辑
摘要: // 基于对象封装一个集合 function Set() { // 属性 this.items = {}; // 方法 // add 往集合中添加元素 Set.prototype.add = function (value) { // 先判断是否有这个元素 if (this.has(value)) 阅读全文
posted @ 2021-06-01 14:57 正经的流刺源 阅读(183) 评论(0) 推荐(0) 编辑
摘要: // 基于数组封装一个哈希表 function HashTable() { // 属性 this.storage = []; this.count = 0; // 数据的存储量 this.limit = 7; // 容量长度最好为质数,利于数据在容器中均匀分布 // 方法 // 哈希函数 HashT 阅读全文
posted @ 2021-06-01 14:55 正经的流刺源 阅读(92) 评论(0) 推荐(0) 编辑
摘要: // 封装一个双向链表 function DoublyLinkedList() { // 内部属性 this.head = null; this.tail = null; this.length = 0; // 内部类,存放节点的数据和指针 function Node(data) { this.da 阅读全文
posted @ 2021-06-01 14:51 正经的流刺源 阅读(72) 评论(0) 推荐(0) 编辑
摘要: // 封装链表 function LinkedList(){ // 创建一个內部类,用于存节点的数据和指针 function Node(data){ this.data = data; this.next = null; } // 链表头 this.head = null; // 链表长度 this 阅读全文
posted @ 2021-06-01 14:49 正经的流刺源 阅读(131) 评论(0) 推荐(0) 编辑
摘要: // 基于数组封装一个栈 function Stack(){ this.items = []; // 压栈 Stack.prototype.push = function(element){ return this.items.push(element) } // 出栈 Stack.prototyp 阅读全文
posted @ 2021-06-01 14:46 正经的流刺源 阅读(304) 评论(0) 推荐(0) 编辑
摘要: // 基于数组封装一个优先级队列 function PriorityQueue(){ this.items = []; // 创建一个内部类,用于存放元素的内容和优先级 function QueueElement(element,priority){ this.element = element; 阅读全文
posted @ 2021-06-01 14:42 正经的流刺源 阅读(53) 评论(0) 推荐(0) 编辑
摘要: // 基于数组封装一个队列 function Queue() { this.items = []; // 将数据存入队列中 Queue.prototype.entryQueue = function (ele) { return this.items.push(ele) } // 数据出队列 Que 阅读全文
posted @ 2021-06-01 14:37 正经的流刺源 阅读(127) 评论(0) 推荐(0) 编辑