![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
贼猫z
这个作者很懒,什么都没留下…
展开
-
常见九种排序算法-Java实现
排序算法比较 1.冒泡排序 依次比较两个相邻的元素列,顺序错误就进行交换,直到排序完成。每次循环都将最大的数值选出来,浮到队列的顶端。平均时间复杂度为 O(n 2),最好情况为 O(n)。 public class BubbleSort { public void bubbleSort(int[] a) { for (int i = 1; i < a.length...原创 2019-08-04 21:38:31 · 214 阅读 · 0 评论 -
递归的时间复杂度计算
子过程规模一样时可以使用以下公式: 其中:N 为父问题的样本量,a为子过程发生的次数,N / b 为被拆分为子问题的样本量,即一步父问题的子过程发生多少次,**O(N^d)**为递归调用子过程之外的复杂度。 ...原创 2019-07-08 12:53:58 · 361 阅读 · 0 评论 -
二叉树的遍历-Java实现
1.前序遍历 public class preOrder { public void preOrder(TreeNode root){ if(root == null) return; Stack<TreeNode> stack = new Stack<>(); stack.push(root); while(!stack.isEmpty()) ...原创 2019-08-04 21:26:32 · 126 阅读 · 0 评论