摘要: 其实排序算法的稳定很简单,就只是当每一个元素都有一个id的时候那么我们该怎么去处理大小相同的元素 如果经过排序后元素大小相同的两个元素的原顺序发生了改变则称它为不稳定排序,反之则称为稳定排序。 冒泡排序:稳定排序 选择排序:不稳定排序 下面是一个代码作为参考(随手写的,没优化过代码,别介意): 阅读全文
posted @ 2016-12-21 11:38 fengsz 阅读(223) 评论(0) 推荐(0) 编辑
摘要: 最近打算重新把基础过一遍,先搞搞排序。 插入排序: 顾名思义,我们就是一次次的不断插入我们的数据以保证他的单调性。就像我们平时斗地主一样的,不断的从右边选出一张牌插到左边,保证每次左边的拍一定比它小就可以了。 插入排序在排序过程中分为已排序部分和未排序部分,不断的从未排序部分拿出数字来向已排序部分插 阅读全文
posted @ 2016-12-21 11:35 fengsz 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 之前刚写完插入排序接下来写写冒泡排序 冒泡排序就像水泡一样不断的上浮,从而达到排序的目的。冒泡排序和插入排序一样也是分成也排序部分和未排序部分。 就是一个重复执行以下步骤的一个过程: 从数组的末尾取一个元素开始依次的向前比较相邻的两个元素,如果大小关系相反则交换位置。 举个例子: A = {5,3, 阅读全文
posted @ 2016-12-21 11:32 fengsz 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 插入和冒泡的排序都写完了,现在再来搞一下选择排序喽。 选则排序其实很简单,同样分成已排序部分和未排序部分。 就只是不断的从未排序部分里将最小值或最大值选出,让他与未排序部分的第一个元素交换位置,重复操作。 举个例子: A = {5,4,8,7,9,3,1}; 1.{5,4,8,7,9,3,1}; | 阅读全文
posted @ 2016-12-21 11:30 fengsz 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Stack Aizu - ALDS1_3_A Write a program which reads an expression in the Reverse Polish notation and prints the computational result. An expression in 阅读全文
posted @ 2016-12-21 11:27 fengsz 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Queue Aizu - ALDS1_3_B For example, we have the following queue with the quantum of 100ms. A(150) - B(80) - C(200) - D(200) First, process A is handle 阅读全文
posted @ 2016-12-21 11:24 fengsz 阅读(280) 评论(0) 推荐(0) 编辑
摘要: Doubly Linked List Aizu - ALDS1_3_C Your task is to implement a double linked list. Write a program which performs the following operations: insert x: 阅读全文
posted @ 2016-12-21 11:21 fengsz 阅读(304) 评论(0) 推荐(0) 编辑
摘要: Areas on the Cross-Section Diagram Aizu - ALDS1_3_D Areas on the Cross-Section Diagram 地域の治水対策として、洪水の被害状況をシミュレーションで仮想してみよう。 図のように $1 \times 1 (m^2)$ の 阅读全文
posted @ 2016-12-21 11:17 fengsz 阅读(144) 评论(0) 推荐(0) 编辑
摘要: Linear Search You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of intege 阅读全文
posted @ 2016-12-21 11:13 fengsz 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Binary Search You are given a sequence of n integers S and a sequence of different q integers T. Write a program which outputs C, the number of intege 阅读全文
posted @ 2016-12-21 11:07 fengsz 阅读(243) 评论(0) 推荐(0) 编辑