![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法
Little Panda
入行中。。。
展开
-
AVL树(自平衡二叉查找树)
这篇文章我是先在博客园发布的:https://www.cnblogs.com/yinhao-ing/p/10732866.html了解AVL树之前要先了解二叉查找树(BST),BST查找元素的时间复杂度平均是O(logN),最坏的情况是O(N),所有的元素都接在左子树(或者右子树)就相当于一串链表了。而AVL树会对子树过高的情况进行优化,这里有个平衡因子的概念,当前节点的平衡因子=左子树高度-...原创 2019-04-18 22:37:47 · 490 阅读 · 0 评论 -
PAT甲级——1118 Birds in Forest (并查集)
1118Birds in Forest(25分)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the...原创 2019-05-05 00:00:59 · 208 阅读 · 0 评论 -
PAT甲级——1119 Pre- and Post-order Traversals(先序+后序序列,建立二叉树)
1119Pre- and Post-order Traversals(30分)Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder t...原创 2019-05-01 13:36:39 · 432 阅读 · 0 评论 -
PAT甲级——1111 Online Map (单源最短路经的Dijkstra算法、priority_queue的使用)
1111Online Map(30分)Input our current position and a destination, an online map can recommend several paths. Now your job is to recommend two paths to your user: one is the shortest, and the other...原创 2019-05-14 23:02:12 · 202 阅读 · 0 评论 -
PAT甲级——1110 Complete Binary Tree (完全二叉树)
1110Complete Binary Tree(25分)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line g...原创 2019-05-18 17:30:50 · 619 阅读 · 0 评论 -
快速排序
快排主要运用了分治策略,每次选一个主元(主元放在它最终的位置上,在它左边的数都比它小,在它右边的数都比它大),从两边往中间寻找,当左边的元素大于等于主元、右边的元素小于等于主元时停下来交换左右两个元素,直到左边界不再小于右边界;然后递归地处理主元左边和右边的数据~~接下来有两个快排的写法:第一种是每次选择左边第一个数作为主元的快排,未做任何优化:int partition(int *...原创 2019-05-28 10:00:13 · 111 阅读 · 0 评论 -
归并排序
归并排序的基本操作是将两个有序数组合并成一个有序数组,原理是运用分治思想,递归地将一个数组的左右两部分有序数列进行归并。C/C++的递归实现:// mergeSort.cpp : 递归写法//#include <stdio.h>#include <stdlib.h>#define elementType int//自定义数据类型using namesp...原创 2019-07-03 18:44:45 · 184 阅读 · 0 评论