![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 63
qq_34891134
这个作者很懒,什么都没留下…
展开
-
快速排序 scala 版 (quick sort)
object Test extends App { def quickSort(arr: Array[Int], low: Int, high: Int): Int = { val p = arr(low) var mid = low; for (i <- low + 1 to high) { if (arr(i) < p) { ...原创 2018-03-30 11:31:11 · 563 阅读 · 0 评论 -
avl树插入(java实现)
public class AvlTree<AnyType extends Comparable<? super AnyType>> { private AvlNode<AnyType> root; private Comparator<? super AnyType> cmp; private static class A...原创 2018-04-09 10:31:08 · 671 阅读 · 0 评论 -
二叉堆 (scala 实现)
class BinaryHeap (args:Int*) { var heap = new ArrayBuffer[Int]() args.foreach(insert) def insert(int: Int): Unit = { if (heap.size == 0) { heap += int return } heap+=int...原创 2018-04-02 14:03:25 · 137 阅读 · 0 评论 -
冒泡排序算法(bubbling sort)
/** * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ * | 平均复杂度 | 最好情况 | 最坏情况 | 空间复杂度 | 排序方式 | 稳定性 | * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * | ...原创 2018-03-27 17:23:33 · 270 阅读 · 0 评论 -
选择排序(selection sort)
算法描述比较相邻的元素。如果第一个比第二个大,就交换它们两个;对每一对相邻元素作同样的工作,从开始第一对到结尾的最后一对,这样在最后的元素应该会是最大的数;针对所有的元素重复以上的步骤,除了最后一个;重复步骤1~3,直到排序完成。算法实现/** * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - _ * | 平...原创 2018-03-28 13:39:11 · 66 阅读 · 0 评论 -
归并排序(merge sort)
算法描述把长度为n的输入序列分成两个长度为n/2的子序列;对这两个子序列分别采用归并排序;将两个排序好的子序列合并成一个最终的排序序列 计算过程/** * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * | 平均复杂度 | 最好情况 | 最坏情况 | 空间...原创 2018-03-29 10:37:41 · 2431 阅读 · 1 评论