随笔分类 - dataStructures&Algorithms
摘要:双向链表可以从前往后查询或者从后往前查询,提高了查询效率。需要存储两个方向的指针,占用了更大的空间。 let DoubleNode = function(element){ this.element = element; this.next = null; this.prior = null; }
阅读全文
摘要:顺序存储结构查询时间复杂度 O(1),插入和删除时间复杂度 O(n) class LinearList{ constructor() { this.arr = []; } // 查询某位置的元素 getElementAt(position) { return this.arr[position];
阅读全文
摘要:单向链表的优势:在同一个位置插入或者删除多次,时间复杂度为 O(1) // 生成一个单向链表 // 辅助类,用来生成结点 let Node = function(element){ this.element = element; this.next = null; } // 链表(查询,添加,插入,
阅读全文