# LeetCodeStudy **Repository Path**: SunshineBrother/LeetCodeStudy ## Basic Information - **Project Name**: LeetCodeStudy - **Description**: 算法学习 - **Primary Language**: Swift - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-02-15 - **Last Updated**: 2022-02-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LeetCodeStudy 数据结构和算法的学习 ## 工具 - [如何直观形象地树状打印一棵二叉树](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/打印树/如何直观形象地树状打印一棵二叉树?.md) ## 数据结构 - [1、算法效率的度量](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法效率的度量.md) - [2、栈和队列](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/栈和队列/栈和队列.md) - [3、链表](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/链表/链表.md) - [4、递归](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/递归/递归.md) - [5、二叉树](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/二叉树/二叉树.md) - [6、集合和映射](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/集合和映射/集合和映射.md) - [7、优先队列](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/优先队列/优先队列.md) - [8、线段树](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/线段树/线段树.md) - [9、Trie](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/Trie/Trie.md) - [10、并查集](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/并查集/并查集.md) - [11、平衡二叉树](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/平衡二叉树/平衡二叉树.md) - [12、哈希表](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/数据结构/哈希表/哈希表.md) *********************************************** ## 算法 在开始之前我们先来写一个帮助测试的函数 ``` // 生成有n个元素的随机数组,每个元素的随机范围为[rangeL, rangeR] func generateRandomArray(count:Int,rangL:Int,rangR:Int) -> Array { if rangR <= rangL{ fatalError("取值范围不准确") } var arr:[Int] = Array() for _ in 0.. Bool { for i in 0.. arr[i+1] { return false } } return true } ``` ![](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/sort.png) 排序算法优越评价有三个指标,执行效率、内存消耗、稳定性,一般来讲,在分析效率时会从几个方面来衡量: - 时间复杂度。会从最好、最坏和平均情况三个来分析; - 时间复杂度的系数、常数 、低阶。在对同一阶时间复杂度的排序算法性能对比的时候,我们就要把系数、常数、低阶也考虑进来。 - 比较次数和交换(或移动)次数。 - [1、冒泡排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/冒泡排序/冒泡排序.md) - [2、选择排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/选择排序/选择排序.md) - [3、插入排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/插入排序/插入排序.md) - [4、希尔排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/希尔排序/希尔排序.md) - [5、归并排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/归并排序/归并排序.md) - [6、快速排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/快速排序/快速排序.md) - [7、堆排序](https://github.com/SunshineBrother/LeetCodeStudy/tree/master/算法/堆排序) - [8、计数排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/计数排序/计数排序.md) - [9、桶排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/桶排序/桶排序.md) - [10、基数排序](https://github.com/SunshineBrother/LeetCodeStudy/blob/master/算法/基数排序/基数排序.md) 排序算法参考: [十大经典排序算法](https://www.runoob.com/w3cnote/ten-sorting-algorithm.html) [五分钟学算法](https://mp.weixin.qq.com/s/vn3KiV-ez79FmbZ36SX9lg)