![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
橘泽
这个作者很懒,什么都没留下…
展开
-
数据结构之冒泡排序,冒泡排序与直接插入排序比较
冒泡排序思想:只会操作相邻的两个元素,每次对相邻的两个元素做大小比较,看是否满足大小关系。 一次冒泡至少会让一个元素移动到最终位置(冒泡)特点:时间复杂度O(n^2)空间复杂度O(1)稳定性排序画图理解一趟排序示意图:程序代码public static void bubbleSort(int[] array) { long start = Syst...原创 2019-05-15 23:26:40 · 567 阅读 · 0 评论 -
数据结构之希尔排序
思想又叫缩小增量法,将待排数组按一定间隔分组,将按间隔分出的记录排序,然后重新按一定间隔(间隔比上一次要大,分出的组数比上一次要少)分组,再排序,直到分组数分为1。特点:时间复杂度:O(N1.3~N1.5)稳定性:不稳定希尔排序是对直接排序的优化画图理解程序代码public static void shell(int[] array,int gap){&nb...原创 2019-05-12 23:33:23 · 245 阅读 · 0 评论 -
数据结构之直接插入排序
思想:将要排序的序列按照每个值的大小逐个插入到一个已经排好序的有序序列中,直到所有的记录插完特点:元素集合越接近有序,直接排序效率越高时间复杂度:O(N^2)空间复杂度:O(1)稳定性:稳定画图说明:程序代码:public static void insertSort(int[] array){ for(int i=1;i<array.lengt...原创 2019-05-12 23:38:57 · 194 阅读 · 0 评论 -
变态跳台阶(动态规划)
题目描述一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。解析:动态规划的考虑角度有4条:1.从问题入手找出能形成递归关系的状态的定义;2.定义状态间的转移方程3.状态的初始化4.返回结果本题从题目中得到状态为求解跳上i级台阶的方法数状态间的转移方程有以下规律:F(i) = F(i-1)+F(i-2)...原创 2019-07-26 13:59:21 · 282 阅读 · 0 评论 -
连续子数组的最大和(动态规划)
题目描述HZ偶尔会拿些专业问题来忽悠那些非计算机专业的同学。今天测试组开完会后,他又发话了:在古老的一维模式识别中,常常需要计算连续子向量的最大和,当向量全为正数的时候,问题很好解决。但是,如果向量中包含负数,是否应该包含某个负数,并期望旁边的正数会弥补它呢?例如:{6,-3,-2,7,-15,1,2,2},连续子向量的最大和为8(从第0个开始,到第3个为止)。给一个数组,返回它的最大连续...原创 2019-07-26 16:07:29 · 1499 阅读 · 0 评论 -
word-break(动态规划)
题目描述Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens =“leetcode”,dict =[“leet...原创 2019-07-27 12:34:34 · 224 阅读 · 0 评论 -
triangle(动态规划)
题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[[2],[3,4],[6,5,7],[4...原创 2019-07-27 15:20:33 · 322 阅读 · 0 评论 -
unique-paths(动态规划)
题目A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach t...原创 2019-07-27 16:06:20 · 137 阅读 · 0 评论