-
Dijkstra
可实现Dijkstra算法,显示起始点到其它各节点的最短距离和路径(Dijkstra algorithm can be implemented to show the shortest distance and path from the starting point to other nodes.)
- 2020-06-25 02:00:02下载
- 积分:1
-
lid-driven-flow(SIMPLE)
计算流体力学重要算法 simple算法计算顶盖驱动流动。(An example for using SIMPLE algorithm to computing lid driven flow in CFD)
- 2021-03-31 22:29:08下载
- 积分:1
-
11087 统计逆序对
Description
设a[0…n-1]是一个包含n个数的数组,若在i<j的情况下,有a[i]>a[j],则称(i, j)为a数组的一个逆序对(inversion)。
比如 <2,3,8,6,1> 有5个逆序对。请采用类似“合并排序算法”的分治思路以O(nlogn)的效率来实现逆序对的统计。
一个n个元素序列的逆序对个数由三部分构成:
(1)它的左半部分逆序对的个数,(2)加上右半部分逆序对的个数,(3)再加上左半部分元素大于右半部分元素的数量。
其中前两部分(1)和(2)由递归来实现。要保证算法最后效率O(nlogn),第三部分(3)应该如何实现?
此题请勿采用O(n^2)的简单枚举算法来实现。
并思考如下问题:
(1)怎样的数组含有最多的逆序对?最多的又是多少个呢?
(2)插入排序的运行时间和数组中逆序对的个数有关系吗?什么关系?
输入格式
第一行:n,表示接下来要输入n个元素,n不超过10000。
第二行:n个元素序列。
输出格式
逆序对的个数。
输入样例
5
2 3 8 6 1
输出样例
5(Set a[0... N-1] is a n array containing n numbers. If there is a [i] > a [j] i n the case of I < j, then (i, j) is a n inversion pair of a array.
For example, <2,3,8,6,1> has five reverse pairs. Please use the idea of "merge sorting algorithm" to achieve the statistics of inverse pairs with O (nlogn) efficiency.
The number of inverse pairs of a sequence of n elements consists of three parts:
(1) The number of reverse pairs in the left half, (2) the number of reverse pairs in the right half, (3) the number of elements in the left half is greater than that in the right half.
The first two parts (1) and (2) are implemented by recursion. To ensure the final efficiency of the algorithm O (nlogn), how should the third part (3) be implemented?
Do not use O (n ^ 2) simple enumeration algorithm to solve this problem.)
- 2019-01-07 23:52:06下载
- 积分:1
-
SP_d
利用Dijkstra算法计算最短有向路小程序(Dijkstra algorithm using the shortest way there is a small program to)
- 2011-06-14 16:00:28下载
- 积分:1
-
beamkm
铁木辛柯梁梁单元有限元程序,可以自动形成刚度阵,质量矩阵(Ironwood oct Ke Liangliang unit finite element program can automatically form stiffness matrix, mass matrix)
- 2021-03-18 11:19:20下载
- 积分:1
-
matlab常用算法程序集
说明: matlab常用算法程序集主要用于解决插值、函数逼近、矩阵特征值计算、数值微分、数值积分、方程求根、非线性方程组求解、解线性方程组的直接法、解线性方程组的迭代法、随机数生成、特殊函数计算、常微分方程的初值等问题(Mainly solve interpolation, function approximation, matrix eigenvalue calculation, numerical differentiation, numerical integration, equation roots, nonlinear equations solving, direct methods for solving linear equations, iterative methods for solving linear equations, random number generation, special functions Calculation, initial value of ordinary differential equations, etc.)
- 2020-07-28 20:58:13下载
- 积分:1
-
A-Novel-Quaternion-Kalman-Filter
一篇关于qkf文献, 量测方程四元素线性推导过程。 (A Novel Quaternion Kalman Filter)
- 2016-09-01 10:58:48下载
- 积分:1
-
srfft
计算复序列的分裂基快速傅里叶变换,分裂基快速算法是将基2和基4分解组合而成。在基2M类快速算法中,分裂基算法具有最少的运算量,且仍保留结构规则、原位计算等优点。(Calculate complex sequence of split radix fast Fourier transform, fast algorithm is to split the base base 2 and base 4 decomposition combination. 2M fast algorithm in the base class, the split-based algorithm has the least amount of computation and structural rules remain in situ calculation and so on.)
- 2013-05-23 19:56:04下载
- 积分:1
-
GGSA
改进的万有引力搜索算法的matlab程序,经过测试,100%可以使用的。(gravitational search algorithm matlab program, after testing, 100% can be used.)
- 2018-06-24 17:56:52下载
- 积分:1
-
nb035
用平面波展开法计算二维声子晶体带隙,可直接计算得到多重分形谱,计算互信息非常有用的一组程序。( Computation Method D phononic bandgap plane wave, It can be directly calculated multi-fractal spectrum, Mutual information is useful to calculate a set of procedures.)
- 2021-03-25 10:09:14下载
- 积分:1