java双端队列的实现-Java实现自定义双端队列(链表和数组两种方式) 数组和链表.pdf
2022-04-18 14:06:46 208KB java 链表 开发语言 数据结构
1. 基于双链表实现双端队列的典型操作(判空、头插、头删、尾插、尾删、普通构造、拷贝构造、赋值运算符重载、析构),编写简单程序使用该双端队列,测试和调试程序。 2. 基于双端队列的头插、头删操作,完成栈的应用:逆波兰表达式求值,测试和调试程序。 3. 基于双端队列的头删、尾插操作,完成普通队列的应用:呼叫中心的离散事件模拟,测试和调试程序。 4. 按要求撰写实验报告、录制程序运行以及讲解程序的视频。
2022-04-06 20:14:35 1.35MB C++ 数据结构 实验报告 双端队列
1
自己写得基于数组的双端队列类模板,初步测试没什么问题,接口不太丰富,各位参考一下吧,也希望能得到反馈
2022-03-25 00:26:09 2KB 双端队列 类模板
1
莫比乌斯反演 平衡规划 双端栈 双端队列 等价类--2021.09.06(E).pdf
2021-09-06 17:15:40 110KB 平衡规划
/* * 基于双向链表实现双端队列结构 */ package dsa; public class Deque_DLNode implements Deque { protected DLNode header;//指向头节点(哨兵) protected DLNode trailer;//指向尾节点(哨兵) protected int size;//队列中元素的数目 //构造函数 public Deque_DLNode() { header = new DLNode(); trailer = new DLNode(); header.setNext(trailer); trailer.setPrev(header); size = 0; } //返回队列中元素数目 public int getSize() { return size; } //判断队列是否为空 public boolean isEmpty() { return (0 == size) ? true : false; } //取首元素(但不删除) public Object first() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); return header.getNext().getElem(); } //取末元素(但不删除) public Object last() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); return trailer.getPrev().getElem(); } //在队列前端插入新节点 public void insertFirst(Object obj) { DLNode second = header.getNext(); DLNode first = new DLNode(obj, header, second); second.setPrev(first); header.setNext(first); size++; } //在队列后端插入新节点 public void insertLast(Object obj) { DLNode second = trailer.getPrev(); DLNode first = new DLNode(obj, second, trailer); second.setNext(first); trailer.setPrev(first); size++; } //删除首节点 public Object removeFirst() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); DLNode first = header.getNext(); DLNode second = first.getNext(); Object obj = first.getElem(); header.setNext(second); second.setPrev(header); size--; return(obj); } //删除末节点 public Object removeLast() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); DLNode first = trailer.getPrev(); DLNode second = first.getPrev(); Object obj = first.getElem(); trailer.setPrev(second); second.setNext(trailer); size--; return(obj); } //遍历 public void Traversal() { DLNode p = header.getNext(); while (p != trailer) { System.out.print(p.getElem()+" "); p = p.getNex
1
自己用C++实现的双端队列数据结构,通过测试,并有注释。有需要的朋友可以看一看
2019-12-21 21:35:14 492KB 双端队列 数据结构 C++
1