当前位置: 首页 > news >正文

已有网站做app需要多少钱百度热搜榜

已有网站做app需要多少钱,百度热搜榜,wordpress文字加框,开源 html5网站模板目录 1.概念 2.队列的使用 3.队列模拟实现 4.循环队列 5.双端队列 6.栈与队列的互相实现 6.1 用队列实现栈 6.2 用栈实现队列 1.概念 #xff08;1#xff09;队列是只允许在一端进行插入数据操作#xff0c;在另一端进行删除数据操作的特殊线性表#xff1b; 1队列是只允许在一端进行插入数据操作在另一端进行删除数据操作的特殊线性表 2队列具有先进先出后进后出的特点 3入队列进行插入操作的一端称为队尾 出队列进行删除操作的一端称为队头 2.队列的使用 在java中Queue是个接口底层是通过链表实现的其常用方法如下 方法功能boolean offer(E e)入队列E poll()出队列peek()获取队头元素int size()获取队列中有效元素的个数boolean isEmpty()检测队列是否为空 3.队列模拟实现 1包类关系 2TestMyQueue package TestMyQueue;import TestMyStack.EmptyException;public class MyQueue {// 使用单链表实现队列static class Node{public int val;public Node next;public Node(int val){this.val val;}}public Node head;public Node last;public int usedSize;public void offer(int val){Node newNode new Node(val);if(head null){head newNode;last newNode;}else{last.next newNode;last newNode;usedSize;}}public int poll(){if(isEmpty()){throw new EmptyException();}int ret head.val;head head.next;return ret;}public boolean isEmpty(){return usedSize 0;}public int peek(){if(isEmpty()){throw new EmptyException();}int ret head.val;return ret;}public int getUseSize(){return usedSize;} } 3EmptyException package TestMyQueue;public class EmptyException extends RuntimeException{public EmptyException(){} } 4.循环队列 题目链接622. 设计循环队列 - 力扣LeetCode 代码 class MyCircularQueue {private int[] elem;private int front; // 表示队列的头private int rear; // 表示队列的尾public MyCircularQueue(int k) {this.elem new int[k1];}public boolean enQueue(int value) {// 入队列判满if(isFull()){return false;}elem[rear] value;rear (rear1)% elem.length;return true;}public boolean deQueue() {// 判空if(isEmpty()){return false;}front (front1)% elem.length;return true;}public int Front() {if(isEmpty()){return -1;}return elem[front];}public int Rear() {if(isEmpty()){return -1;}int index (rear0)?elem.length-1:rear-1;return elem[index];}public boolean isEmpty() {return front rear;}public boolean isFull() {// 写法1 // if( (rear1) % elem.length front){ // return true; // } // return false;// 写法2return (rear1)% elem.length front;} } 5.双端队列 双端队列是指允许两端都可以进行入队和出队操作的队列 Deque是一个接口使用时必须创建其实现类类的对象 常用的实现类为ArrayDeque由数组实现的双端队列和LinkedList由双向链表实现的双端队列故而实例化Deque的方式有以下两种  // 链式双端队列DequeInteger deque new LinkedList();// 数组双端队列DequeInteger deque2 new ArrayDeque(); 注也可以使用Deque实现顺序栈 实际上以下写法 StackInteger stack new Stack(); 即直接使用Stack类实例化栈对象是很少用的可以使用ArrayDeque创建顺序栈对象 DequeInteger stack2 new ArrayDeque(); 6.栈与队列的互相实现 6.1 用队列实现栈 题目链接225. 用队列实现栈 - 力扣LeetCode 解题思路使用两个队列实现栈元素入栈至不为空的队列元素出栈在不为空的队列出栈size-1个元素最后余下的元素就是要出栈的元素如果两个队列均为空则入第一个队列 代码 public class MyStack {private QueueInteger queue1;private QueueInteger queue2;public MyStack() {queue1 new LinkedList();queue2 new LinkedList();}public void push(int x) {if(!queue1.isEmpty()){queue1.offer(x);}else if(!queue2.isEmpty()){queue2.offer(x);}else{queue1.offer(x);}}public int pop() {if(empty()){// 当前栈为空return -1;}if(!queue1.isEmpty()){int size queue1.size();for(int i0;isize-1;i){//for(int i0;iqueue1.size()-1;i){ //写法错误,poll会导致size变化int ret queue1.poll();queue2.offer(ret);}return queue1.poll();}else{int size queue2.size();for(int i0;isize-1;i){int ret queue2.poll();queue1.offer(ret);}return queue2.poll();}}public int top() {if(empty()){return -1;}if(!queue1.isEmpty()){int size queue1.size();int ret -1;for(int i0;isize;i){ret queue1.poll();queue2.offer(ret);}return ret;}else{int size queue2.size();int ret -1;for(int i0;isize;i){ret queue2.poll();queue1.offer(ret);}return ret;}}public boolean empty() {return queue1.isEmpty() queue2.isEmpty();} } 6.2 用栈实现队列 题目链接232. 用栈实现队列 - 力扣LeetCode 解题思路使用两个栈实现队列stack1用于入栈元素当需要出栈元素时若stack2不为空直接出栈stack2栈顶元素如果stack2为空就将stack1的所有元素入栈到stack2中再出栈stack2顶元素即可 代码 class MyQueue {private StackInteger stack1;private StackInteger stack2;public MyQueue() {stack1 new Stack();stack2 new Stack();}public void push(int x) {stack1.push(x);}public int pop() {if(empty()){return -1;}if(stack2.empty()){while(!stack1.empty()){stack2.push(stack1.pop());}}return stack2.pop();}public int peek() {if(empty()){return -1;}if(stack2.empty()){while(!stack1.empty()){stack2.push(stack1.pop());}}return stack2.peek();}public boolean empty() {return stack1.empty() stack2.empty();} }
http://www.zqtcl.cn/news/380652/

相关文章:

  • 自己做网站的成本要哪些东西wordpress resize
  • 网站建设总体流程wordpress 浮窗音乐
  • 福州网站建设公司哪个网站可以做前端项目
  • 十二冶金建设集团有限公司网站wordpress安装在哪里
  • 怎么做网站源码wordpress的rss
  • wordpress能不能做企业网站软件技术和计算机网络技术哪个好
  • 甘肃省住房和城乡建设部网站首页ip怎么做网站
  • 怎么开一家网站开发公司百度推广一年大概需要多少钱
  • 小破站下载h5企业模板网站
  • 服务器怎么设置ip做网站凌云seo博客
  • 莱芜四大金刚是谁啊镇江网站优化推广
  • 上海门户网站开发企业号码查询系统
  • 西安做网站设计的公司golang 网站开发 教程
  • 做网站哪些公司专业做app软件开发公司
  • 蒙特网站建设湖北省建设厅网站上岗证查询
  • 宁波网站建设 联系哪家电子商务网站建设过程范文
  • 南宁商城网站建设网站建设的需求文档
  • dedeampz 部署wordpress 网站访问慢如何评价网站是否做的好处
  • 怎样建设个人影视网站设计学专业
  • 没有公司 接单做网站网站建设加盟合作
  • 如何将域名和网站绑定做网站找投资人
  • 网站开发 平台WordPress首页可见
  • 沧州做网站费用打开上海发布
  • 重庆潼南网站建设公司电话网站能调用一些字体
  • 摄影网站设计素材做彩票网站电话多少
  • 开网站公司企业管理网课
  • 相城高端网站建设施工建设集团网站
  • .电子商务网站的开发原则包括网络服务示范区创建情况
  • 网站如何做权重php做网站登陆验证
  • 昆山制造网站的地方网站建设 有聊天工具的吗