算法题总结(十)——二叉树上

#二叉树的递归遍历

// 前序遍历·递归·LC144_二叉树的前序遍历
class Solution {public List<Integer> preorderTraversal(TreeNode root) {List<Integer> result = new ArrayList<Integer>();  //也可以把result 作为全局变量,只需要一个函数即可。preorder(root, result);return result;}public void preorder(TreeNode root, List<Integer> result) {if (root == null) {return;}result.add(root.val);preorder(root.left, result);preorder(root.right, result);}
}
// 中序遍历·递归·LC94_二叉树的中序遍历
class Solution {public List<Integer> inorderTraversal(TreeNode root) {List<Integer> res = new ArrayList<>();inorder(root, res);return res;}void inorder(TreeNode root, List<Integer> list) {if (root == null) {return;}inorder(root.left, list);list.add(root.val);             // 注意这一句inorder(root.right, list);}
}
// 后序遍历·递归·LC145_二叉树的后序遍历
class Solution {public List<Integer> postorderTraversal(TreeNode root) {List<Integer> res = new ArrayList<>();postorder(root, res);return res;}void postorder(TreeNode root, List<Integer> list) {if (root == null) {return;}postorder(root.left, list);postorder(root.right, list);list.add(root.val);             // 注意这一句}
}

后面写二叉树的递归算法,****就是要注意1、采用什么递归遍历 2、对结点的处理逻辑

一般是中左右,对中结点进行处理。

如果需要用到左右结点的返回值的,使用后续遍历,左右中。

#二叉树的迭代遍历

前序和中序是完全两种代码风格,这是因为前序遍历中访问节点(遍历节点)和处理节点(将元素放进result数组中)可以同步处理****,但是中序就无法做到同步!

对于中序遍历可以用一个指针来访问节点,访问到最底层,每次将访问的节点放进栈,如果访问到了最底层,将访问的节点放进栈。

再来看后序遍历,先序遍历是中左右,后续遍历是左右中,那么我们只需要调整一下先序遍历的代码顺序,就变成中右左的遍历顺序,然后在反转result数组,输出的结果顺序就是左右中了。

二叉树的非递归遍历要使用栈。

// 前序遍历顺序:中-左-右,入栈顺序:中-右-左
class Solution {public List<Integer> preorderTraversal(TreeNode root) {List<Integer> result = new ArrayList<>();if (root == null){return result;  //返回空链表}Stack<TreeNode> stack = new Stack<>();stack.push(root);while (!stack.isEmpty()){TreeNode node = stack.pop();result.add(node.val);if (node.right != null){stack.push(node.right);}if (node.left != null){stack.push(node.left);}}return result;}
}// 中序遍历顺序: 左-中-右 入栈顺序: 左-右
class Solution {public List<Integer> inorderTraversal(TreeNode root) {List<Integer> result = new ArrayList<>();if (root == null){return result;}Stack<TreeNode> stack = new Stack<>();TreeNode cur = root;while (cur != null || !stack.isEmpty()){if (cur != null){   // 指针来访问节点,访问到最底层stack.push(cur);  // 指针来访问节点,访问到最底层  不等于空,入栈并指向左孩子cur = cur.left;}else{               //从栈里弹出的数据,就是要处理的数据(放进result数组里的数据)cur = stack.pop();result.add(cur.val); //中cur = cur.right;  //右}}return result;}
}// 后序遍历顺序 左-右-中 入栈顺序:中-左-右 出栈顺序:中-右-左, 最后翻转结果
class Solution {public List<Integer> postorderTraversal(TreeNode root) {List<Integer> result = new ArrayList<>();if (root == null){return result;}Stack<TreeNode> stack = new Stack<>();stack.push(root);while (!stack.isEmpty()){TreeNode node = stack.pop();result.add(node.val);if (node.left != null){   //先放左子树,再放右子树stack.push(node.left);}if (node.right != null){stack.push(node.right);}}Collections.reverse(result);  return result;}
}

二叉树的层序遍历

102、二叉树的层序遍历

一层一层的处理

class Solution {public List<List<Integer>> levelOrder(TreeNode root) {List<List<Integer>> result= new ArrayList<>();if(root==null)  return result;Queue<TreeNode> queue =new LinkedList<>();queue.add(root);while(!queue.isEmpty())  //控制层数{List<Integer> tmp=new ArrayList<>();  //每次都新建一个ArrayList  防止被修改int len=queue.size();  //每层的个数while(len>0)  //遍历每层的结点,也可以使用for循环{TreeNode node =queue.poll();tmp.add(node.val);if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}result.add(tmp);}return result;}
}

#107、二叉树的层序遍历二

给你二叉树的根节点 root ,返回其节点值 自底向上的层序遍历 。 (即按从叶子节点所在层到根节点所在的层,逐层从左向右遍历)

示例 1:

输入:root = [3,9,20,null,null,15,7]
输出:[[15,7],[9,20],[3]]

示例 2:

输入:root = [1]
输出:[[1]]

示例 3:

输入:root = []
输出:[]

把每层的列表从头插入结果中就可以

class Solution {public List<List<Integer>> levelOrderBottom(TreeNode root) {List<List<Integer>> ans= new ArrayList<List<Integer>>();if(root==null) return ans;Queue<TreeNode> queue =new LinkedList<>();queue.add(root);while(!queue.isEmpty()){List<Integer> tmp= new ArrayList<>();int len=queue.size();while(len>0){TreeNode node =queue.poll();tmp.add(node.val);if(node.left!=null) queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}ans.add(0,tmp);  //每次都从头开始插入}return ans;}
}

#199、二叉树的右视图

给定一个二叉树的 根节点root,想象自己站在它的右侧,按照从顶部到底部的顺序,返回从右侧所能看到的节点值。

示例 1:

输入: [1,2,3,null,5,null,4]
输出: [1,3,4]

示例 2:

输入: [1,null,3]
输出: [1,3]

示例 3:

输入: []
输出: []

即利用队列的长度,把每一层的最后一个结点加入结果中

class Solution {public List<Integer> rightSideView(TreeNode root) {//即看到的都是每一层的最后一个结点List<Integer> ans =new ArrayList<>();Queue<TreeNode> queue =new LinkedList<>();if(root==null) return ans; //一定要判断为空的情况,否则会空指针异常queue.add(root);while(!queue.isEmpty()){int len =queue.size();while(len>0){TreeNode node =queue.poll();if(len==1) ans.add(node.val);  //把每一层的最后一个结点加入if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}}return ans;}
}

637、二叉树的层平均值

给定一个非空二叉树的根节点 root , 以数组的形式返回每一层节点的平均值。与实际答案相差 10-5 以内的答案可以被接受。

示例 1:

输入:root = [3,9,20,null,null,15,7]
输出:[3.00000,14.50000,11.00000]
解释:第 0 层的平均值为 3,第 1 层的平均值为 14.5,第 2 层的平均值为 11 。
因此返回 [3, 14.5, 11] 。

使用一个sum来计算每层的和

class Solution {public List<Double> averageOfLevels(TreeNode root) {List<Double> ans =new ArrayList<>();Queue<TreeNode> queue =new LinkedList<>();queue.add(root);while(!queue.isEmpty()){int len =queue.size();int n=len;double sum=0;while(len>0){TreeNode node =queue.poll();sum += node.val;if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}ans.add(sum/n);}return ans;}
}

429、N叉树的层序遍历

给定一个 N 叉树,返回其节点值的层序遍历。(即从左到右,逐层遍历)。

树的序列化输入是用层序遍历,每组子节点都由 null 值分隔(参见示例)。

示例 1:

输入:root = [1,null,3,2,4,null,5,6]
输出:[[1],[3,2,4],[5,6]]
class Solution {public List<List<Integer>> levelOrder(Node root) {List<List<Integer>> ans= new ArrayList<List<Integer>>();Queue<Node> queue = new LinkedList<>();if(root==null) return ans;queue.add(root);while(!queue.isEmpty()){int len =queue.size();List<Integer> tmp=new ArrayList<>();while(len>0){Node node =queue.poll();tmp.add(node.val);len--;List<Node> childrens =node.children;for(Node c:childrens){if(c!=null) queue.add(c);}}ans.add(tmp);}return ans;   }
}

515、找出每层的最大值

给定一棵二叉树的根节点 root ,请找出该二叉树中每一层的最大值。

示例1:

输入: root = [1,3,2,5,3,null,9]
输出: [1,3,9]
class Solution {public List<Integer> largestValues(TreeNode root) {List<Integer> ans =new ArrayList<>();if(root==null) return ans;Queue<TreeNode> queue =new LinkedList<>();queue.add(root);while(!queue.isEmpty()){int len =queue.size();int max=Integer.MIN_VALUE; //记录每一层的最大值while(len>0){TreeNode node = queue.poll();if(node.val>max)max=node.val;if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}ans.add(max);}return ans;}
}

116、填充每个节点的下一个右侧节点指针

给定一个 完美二叉树 ,其所有叶子节点都在同一层,每个父节点都有两个子节点。二叉树定义如下:

struct Node {int val;Node *left;Node *right;Node *next;
}

填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL。

初始状态下,所有 next 指针都被设置为 NULL。

示例 1:

class Solution {public Node connect(Node root) {Queue<Node> queue =new LinkedList<>();if(root==null)  return root;queue.add(root);while(!queue.isEmpty()){int len =queue.size();while(len>0){   Node node = queue.poll();  //本质上还是找到每层的最后一个结点if(len==1){node.next=null;}else{Node nextNode =queue.peek();node.next=nextNode;}len--;if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);}}return root;}
}

#104、 二叉树的最大深度

使用前序求的就是深度,使用后序呢求的是高度

层序遍历:

class Solution {public int maxDepth(TreeNode root) {if(root==null) return 0;Queue<TreeNode> queue = new LinkedList<>();queue.add(root);int hight=0;while(!queue.isEmpty()){int len=queue.size();while(len>0){TreeNode node =queue.poll();if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}hight++;}return hight;}
}

后续遍历:

class Solution {public int maxDepth(TreeNode root) {if(root==null) return 0;int leftDepth =maxDepth(root.left); //左int rightDepth =maxDepth(root.right);  //右return Math.max(leftDepth,rightDepth)+1; //中}
}

前序遍历:

class Solution {public:int result;//使用result来记录最大深度void getDepth(TreeNode* node, int depth) {result = depth > result ? depth : result; // 中if (node->left == NULL && node->right == NULL) return ;if (node->left) { // 左getDepth(node->left, depth + 1);}if (node->right) { // 右getDepth(node->right, depth + 1);}return ;}int maxDepth(TreeNode* root) {result = 0;if (root == 0) return result;getDepth(root, 1);return result;}
};

101、 二叉树的最小深度

给定一个二叉树,找出其最小深度。

最小深度是从根节点到最近叶子节点的最短路径上的节点数量。

说明:叶子节点是指没有子节点的节点。

示例 1:

输入:root = [3,9,20,null,null,15,7]
输出:2

即当左右孩子都为空的时候就返回

层序遍历

class Solution {public int minDepth(TreeNode root) {if(root==null) return 0;Queue<TreeNode> queue = new LinkedList<>();queue.add(root);int depth=0;while(!queue.isEmpty()){int len=queue.size();depth++;while(len>0){TreeNode node =queue.poll();if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);if(node.right==null && node.left==null)return depth;len--;}}return depth;}
}

递归法

如果左子树为空,右子树不为空,说明最小深度是 1 + 右子树的深度。

反之,右子树为空,左子树不为空,最小深度是 1 + 左子树的深度。 最后如果左右子树都不为空,返回左右子树深度最小值 + 1 。

class Solution {//递归法public int minDepth(TreeNode root) {if(root==null) return 0;int leftDepth = minDepth(root.left);int rightDepth = minDepth(root.right);if(root.left==null)return rightDepth+1; //否则没有左孩子的分支会被当成最小值if(root.right==null)return leftDepth+1;return Math.min(leftDepth,rightDepth)+1;}
}

#226、翻转二叉树

给你一棵二叉树的根节点 root ,翻转这棵二叉树,并返回其根节点。

示例 1:

输入:root = [4,2,7,1,3,6,9]
输出:[4,7,2,9,6,3,1]

采用层序遍历,每取出一个结点就交换其左右孩子

class Solution {public TreeNode invertTree(TreeNode root) {//采用层序遍历Queue<TreeNode> queue =new LinkedList<>();if(root==null)  return root;queue.add(root);while(!queue.isEmpty()){int len =queue.size();while(len>0){TreeNode node=queue.poll();TreeNode tmp =node.right;node.right=node.left;node.left=tmp;if(node.left!=null) queue.add(node.left);if(node.right!=null) queue.add(node.right);len--;}}return root;}
}

递归法:

对一个结点交换左右,然后进行左右递归

class Solution {/*** 前后序遍历都可以* 中序不行,因为先左孩子交换孩子,再根交换孩子(做完后,右孩子已经变成了原来的左孩子),再右孩子交换孩子(此时其实是对原来的左孩子做交换)*/public TreeNode invertTree(TreeNode root) {if (root == null) {return null;}invertTree(root.left);invertTree(root.right);swapChildren(root);    //也可以中左右return root;}private void swapChildren(TreeNode root) {TreeNode tmp = root.left;root.left = root.right;root.right = tmp;}
}

#114、二叉树展开为链表

给你二叉树的根结点 root ,请你将它展开为一个单链表:

  • 展开后的单链表应该同样使用 TreeNode ,其中 right 子指针指向链表中下一个结点,而左子指针始终为 null 。
  • 展开后的单链表应该与二叉树 先序遍历 顺序相同。

示例 1:

输入:root = [1,2,5,3,4,null,6]
输出:[1,null,2,null,3,null,4,null,5,null,6]
class Solution {//保存前序遍历的结果List<TreeNode> list=new ArrayList<>();public void flatten(TreeNode root) {preorder(root);for(int i=1;i<list.size();i++){TreeNode pre=list.get(i-1);TreeNode cur=list.get(i);pre.left=null;pre.right=cur;}}//构造树,然后值是结点public void preorder(TreeNode root){if(root==null)return;list.add(root);preorder(root.left);preorder(root.right);}
}

递归+回溯的思路,将前序遍历反过来遍历,那么第一次访问的就是前序遍历中最后一个节点。那么可以调整最后一个节点,再将最后一个节点保存到pre里,再调整倒数第二个节点,将它的右子树设置为pre,再调整倒数第三个节点,依次类推直到调整完毕。和反转链表的递归思路是一样的。

class Solution {//反前序遍历TreeNode pre;public void flatten(TreeNode root) {if(root==null)return;flatten(root.right);flatten(root.left);//先找到最后一个结点,然后记录root.left=null;root.right=pre;pre=root;}}

#101、对称二叉树

给你一个二叉树的根节点 root , 检查它是否轴对称。

示例 1:

输入:root = [1,2,2,3,4,4,3]
输出:true

示例 2:

输入:root = [1,2,2,null,3,null,3]
输出:false

使用一个队列,类似于层序遍历的方式,只不过不用加len来判断层数,并且空结点也要入队。

而本题的迭代法中我们使用了队列,需要注意的是这不是层序遍历,而且仅仅通过一个容器来成对的存放我们要比较的元素,

class Solution {public boolean isSymmetric(TreeNode root) {//把空节点也看成结点Queue<TreeNode> queue =new LinkedList<>();queue.add(root.left);queue.add(root.right);while(!queue.isEmpty()){//不符合就返回falseTreeNode leftnode =queue.poll();    //每次取出需要比较的两个结点TreeNode rightnode =queue.poll();    //每次取出需要比较的两个结点if(leftnode==null && rightnode ==null)continue;if(leftnode==null||rightnode==null||leftnode.val!=rightnode.val)return false;queue.add(leftnode.left);queue.add(rightnode.right);queue.add(leftnode.right);queue.add(rightnode.left);}return true;}
}

递归法:

class Solution {private boolean copmare(TreeNode leftnode, TreeNode rightnode){if(leftnode==null && rightnode!=null) return false;else if(leftnode!=null && rightnode==null) return false;else if(leftnode==null && rightnode==null) return true;else if(leftnode.val!=rightnode.val) return false;    //也可以合在一起判断else  //说明leftnode和rightnode相等return copmare(leftnode.left,rightnode.right) && copmare(leftnode.right,rightnode.left);}public boolean isSymmetric(TreeNode root) {return copmare(root.left,root.right);}
}

100、相同的树

给你两棵二叉树的根节点 p 和 q ,编写一个函数来检验这两棵树是否相同。

如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。

示例 1:

输入:p = [1,2,3], q = [1,2,3]
输出:true

和对称二叉树一样

class Solution {public boolean isSameTree(TreeNode p, TreeNode q) {//使用同一个队列Queue<TreeNode> queue =new LinkedList<>();queue.add(p);queue.add(q);while(!queue.isEmpty()){TreeNode node1 =queue.poll();TreeNode node2 =queue.poll();if(node1==null && node2==null)continue;else if(node1==null &&node2!=null)return false;else if(node1!=null && node2==null)return false;else if(node1.val!=node2.val)return false;queue.add(node1.left);queue.add(node2.left);queue.add(node1.right);queue.add(node2.right);}return true;}
}

递归法

class Solution {//递归法:求树是否相等public boolean isSameTree(TreeNode p, TreeNode q) {if(p==null&& q==null) return true;else if(p==null &&q!=null) return false;else if(p!=null &&q==null) return false;else if(p.val!=q.val) return false;else  //即结点相同,判读左右结点{return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);}}
}

572、另一棵树的子树

给你两棵二叉树 root 和 subRoot 。检验 root 中是否包含和 subRoot 具有相同结构和节点值的子树。如果存在,返回 true ;否则,返回 false 。

二叉树 tree 的一棵子树包括 tree 的某个节点和这个节点的所有后代节点。tree 也可以看做它自身的一棵子树。

示例 1:

输入:root = [3,4,5,1,2], subRoot = [4,1,2]
输出:true

采用遍历+判断树是否相等

class Solution {public boolean isSameTree(TreeNode p, TreeNode q){if(p==null && q==null)  return true;else if(p==null||q==null||p.val!=q.val)  return false;  //直接合在一起写else{ //说明结点值相同return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);}}public boolean isSubtree(TreeNode root, TreeNode subRoot) {Queue<TreeNode> queue =new LinkedList<>();queue.add(root);while(!queue.isEmpty()){TreeNode node =queue.poll();if(isSameTree(node,subRoot))return true;if(node.left!=null) queue.add(node.left);if(node.right!=null) queue.add(node.right);}return false;}
}

559、n叉树的最大深度

class Solution {/*递归法,后序遍历求root节点的高度*/public int maxDepth(Node root) {if (root == null) return 0;  //递归出口int depth = 0;if (root.children != null){for (Node child : root.children){depth = Math.max(depth, maxDepth(child));}}return depth + 1; //中节点}  
}

#110、平衡二叉树

在递归法求高度的基础上,每次递归要判断是否是平衡二叉树。

class Solution {  //递归法求高度,因为是求高度,所以是后序遍历:左右中private int getHight(TreeNode root){if(root==null) return 0;int leftHight=getHight(root.left);if(leftHight==-1) return -1;    //用-1代表不是平衡二叉树int rightHight=getHight(root.right);if(rightHight==-1) return -1;if(Math.abs(leftHight-rightHight)>1)return -1;return Math.max(leftHight,rightHight)+1;}public boolean isBalanced(TreeNode root) {if(getHight(root)==-1) return false;elsereturn true;}
}

层序遍历

class Solution {  //层次遍历求高度private int getHigth(TreeNode root) {if(root==null) return 0;Queue<TreeNode> queue = new LinkedList<>();queue.add(root);int hight=0;while(!queue.isEmpty()){int len=queue.size();while(len>0){TreeNode node =queue.poll();if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}hight++;}return hight;}//层次遍历判断public boolean isBalanced(TreeNode root) {if(root==null) return true;Queue<TreeNode> queue = new LinkedList<>();queue.add(root);while(!queue.isEmpty()){int len=queue.size();while(len>0){TreeNode node =queue.poll();int leftHight =getHigth(node.left);int rightHight =getHigth(node.right);if(Math.abs(leftHight-rightHight)>1)return false;if(node.left!=null)queue.add(node.left);if(node.right!=null)queue.add(node.right);len--;}}return true;}
}

#543、二叉树的直径

给你一棵二叉树的根节点,返回该树的 直径

二叉树的 直径 是指树中任意两个节点之间最长路径的 长度 。这条路径可能经过也可能不经过根节点 root 。

两节点之间路径的 长度 由它们之间边数表示。

示例 1:

输入:root = [1,2,3,4,5]
输出:3
解释:3 ,取路径 [4,2,1,3] 或 [5,2,1,3] 的长度。

示例 2:

输入:root = [1,2]
输出:1

一开始以为就是根节点的左右子树的深度之和,后来发现最长路径不一定经过根结点。

class Solution {//直径,即树中找最长路径,最长路径不一定经过根结点//对于经过的每一个结点来说,最长路径就是左右子树的深度 之和int maxd=0;  //记录最大直径public int diameterOfBinaryTree(TreeNode root) {height(root);return maxd; }//递归求深度public int height(TreeNode root){if(root==null)return 0;int left=height(root.left);int right=height(root.right);//在遍历的过程中找以每个结点为根的最大直径maxd=Math.max(maxd,left+right); //将每个节点最大直径(左子树深度+右子树深度)当前最大值比较并取大者return Math.max(left,right)+1;  //返回结点深度}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/bicheng/55774.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Linus Torvalds 要求内核开发人员编写更好的 Git 合并提交信息

昨天在宣布 Linux 6.12-rc2 内核时&#xff0c;Linus Torvalds 要求内核维护者在提交信息方面做得更好。Torvalds 尤其希望内核维护者在描述拉取请求中的变更时&#xff0c;能更好地使用积极、命令式的语气。 Linux创建者在6.12-rc2 公告中解释道&#xff1a; 总之&#xff0c…

论文阅读笔记-XLNet: Generalized Autoregressive Pretraining for Language Understanding

前言 Google发布的XLNet在问答、文本分类、自然语言理解等任务上都大幅超越BERT,XLNet提出一个框架来连接语言建模方法和预训练方法。我们所熟悉的BERT是denoising autoencoding模型,最大的亮点就是能够获取上下文相关的双向特征表示,所以相对于标准语言模型(自回归)的预…

【AIGC】ChatGPT提示词Prompt高效编写模式:结构化Prompt、提示词生成器与单样本/少样本提示

博客主页&#xff1a; [小ᶻZ࿆] 本文专栏: AIGC | ChatGPT 文章目录 &#x1f4af;前言&#x1f4af;结构化Prompt (Structured Prompt)组成元素应用实例优势结论 &#x1f4af;提示词生成器 (Prompt Creator)如何工作应用实例优势结论 &#x1f4af;单样本/少样本提示 (O…

什么是安全运营中心 SOC?

SOC 代表安全运营中心&#xff0c;它是任何企业中负责组织安全、保护企业免受网络风险的单一、集中的团队或职能。 安全运营中心将管理和控制业务运营的所有安全要素&#xff0c;从监控资产到雇用合适的人员和流程&#xff0c;再到检测和应对威胁。 在本文中&#xff0c;我们…

PHP变量(第④篇)

本栏目教学是php零基础到精通&#xff0c;如果你还没有安装php开发工具请查看下方链接&#xff1a; Vscode、小皮面板安装-CSDN博客 今天来讲一讲php中的变量&#xff0c;变量是用于存储信息的"容器"&#xff0c;这些数据可以在程序执行期间被修改&#xff08;即其…

ThinkBook 16+ 锐龙6800h 安装ubuntu键盘失灵

问题&#xff1a;在ThinkBook 16 锐龙6800h 安装ubuntu18.04 出现笔记本键盘按下延迟非常高&#xff0c;输出卡死的情况&#xff0c;但是外接键盘可以正常使用 解决&#xff1a;更新内核 1、进入 https://kernel.ubuntu.com/~kernel-ppa/mainline/ 下载所需内核版本&#x…

Node.js+Express毕设论文选题最新推荐题目和方向

目录 一、前言 二、毕设选题推荐 三、总结 四、附录&#xff08;手册、官网、资源教程等&#xff09; 1. Node.js 官方资源 2. Express 官方资源 3.安装方法 4 创建示例 一、前言 Node.js 是一个基于 Chrome V8 引擎的 JavaScript 运行环境&#xff0c;它允许开发者使用…

智能医疗:Spring Boot医院管理系统开发

2相关技术 2.1 MYSQL数据库 MySQL是一个真正的多用户、多线程SQL数据库服务器。 是基于SQL的客户/服务器模式的关系数据库管理系统&#xff0c;它的有点有有功能强大、使用简单、管理方便、安全可靠性高、运行速度快、多线程、跨平台性、完全网络化、稳定性等&#xff0c;非常适…

x++、++x的一些问题

x、x在字面上无非就说一个先前置递增然后再运算&#xff0c;另一个是运算完再递增&#xff0c;是不是有些许模棱两可的感觉&#xff0c;接下来引用一个简单的for循环就能够大致理解&#xff1a; 先是x&#xff1a; int i0,x0;for(i0;(i)<5;){xi;printf("%d\n",x)…

ubuntu 安装baget

一、安装netcore3.1 环境 二、下载运行文件 下载&#xff1a;github.com/loic-sharma/BaGet/releases 修改&#xff1a;appsettings.json文件 mkdir -p /root/apps/baget mkdir -p /root/apps/datas touch /root/apps/baget.db cd /root/apps/baget dotnet BaGet.dll --urls&…

Android Framework(八)WMS-窗口动效概述

文章目录 动画简述本地、远端动画的定义什么是“leash”图层“leash”图层的命令与创建 Winscope流程小结 动画流程概览分析Activity启动app_transition 动画的主要事件触发动画执行的套路动画真正执行动画的结束回调触发远端动画的Target 动画简述 1、动画的原理也是利用了视觉…

思科dhcp的配置

以路由器为例 让pc3 自动获取ip地址并获取的网段为172.16.4.100-172.16.4.200 配置如下&#xff1a; R1(config)#interface GigabitEthernet0/2 R1(config)#ip address 172.16.4.254 255.255.255.0 R1(config)# no shutdown R1(config)#ip dhcp pool 4_pool //创建dhcp地址池…

如何使用 Python 读取数据量庞大的 excel 文件

使用 pandas.read_excel 读取大文件时&#xff0c;的确会遇到性能瓶颈&#xff0c;特别是对于10万行20列这种规模的 .xlsx 文件&#xff0c;常规的 pandas 方法可能会比较慢。 要提高读取速度&#xff0c;关键是找到更高效的方式处理 Excel 文件&#xff0c;特别是在 Python 的…

毕业设计项目——基于transformer的中文医疗领域命名实体识别(论文/代码)

完整的论文代码见文章末尾 以下为核心内容 摘要 近年来&#xff0c;随着深度学习技术的发展&#xff0c;基于Transformer和BERT的模型在自然语言处理领域取得了显著进展。在中文医疗领域&#xff0c;命名实体识别(Named Entity Recognition, NER)是一项重要任务&#xff0c;旨…

uniapp实战教程:如何封装一个可复用的表单组件

在uniapp开发过程中&#xff0c;表单组件的使用场景非常广泛。为了提高开发效率&#xff0c;我们可以将常用的表单组件进行封装。本文将带你了解如何在uniapp中封装一个表单组件&#xff0c;让你只需要通过属性配置轻松实现各种表单&#xff0c;效果图如下&#xff1a; 一、准备…

如何利用免费音频剪辑软件制作出精彩音频

现在有许多免费的音频剪辑软件可供选择&#xff0c;它们为广大用户提供了丰富的功能和便捷的操作体验&#xff0c;让音频编辑变得更加轻松和有趣。接下来&#xff0c;让我们一起走进这些免费音频剪辑软件的世界&#xff0c;探索它们的独特魅力和强大功能。 1.福昕音频剪辑 链…

【Nacos入门到实战十四】Nacos配置管理:集群部署与高可用策略

个人名片 &#x1f393;作者简介&#xff1a;java领域优质创作者 &#x1f310;个人主页&#xff1a;码农阿豪 &#x1f4de;工作室&#xff1a;新空间代码工作室&#xff08;提供各种软件服务&#xff09; &#x1f48c;个人邮箱&#xff1a;[2435024119qq.com] &#x1f4f1…

点云补全 学习笔记

目录 Depth completion with convolutions and vision transformers 依赖项&#xff1a; DCNv2 softpoolnet Depth completion with convolutions and vision transformers Zhang, Y., Guo, X., Poggi, M., Zhu, Z., Huang, G., Mattoccia, S.: Completionformer: Depth co…

docker运行arm64架构的镜像、不同平台镜像构建

背景 Docker 允许开发者将应用及其依赖打包成一个轻量级、可移植的容器&#xff0c;实现“一次构建&#xff0c;到处运行”的目标。然而&#xff0c;不同的操作系统和硬件架构对容器镜像有不同的要求。例如&#xff0c;Linux 和 Windows 系统有不同的文件系统和系统调用&#…

【预备理论知识——2】深度学习:线性代数概述

简单地说&#xff0c;机器学习就是做出预测。 线性代数 线性代数是数学的一个分支&#xff0c;主要研究向量空间、线性方程组、矩阵理论、线性变换、特征值和特征向量、内积空间等概念。它是现代数学的基础之一&#xff0c;并且在物理学、工程学、计算机科学、经济学等领域有着…