首页 | 本学科首页   官方微博 | 高级检索  
     检索      

基于树状数组的逆序数计算方法
引用本文:周娟,曹义亲,谢昕.基于树状数组的逆序数计算方法[J].华东交通大学学报,2011,28(2):45-49.
作者姓名:周娟  曹义亲  谢昕
作者单位:1. 华东交通大学,软件学院,江西,南昌,330013
2. 华东交通大学,信息学院,江西,南昌,330013
基金项目:国家自然科学基金项目,江西省自然科学基金项目,华东交通大学科学研究项目
摘    要:n个元素组成的置换a1],a2],…,an].若i<j且ai]>aj],则称(ai],aj])是一个逆序对.置换中逆序对的个数称为置换的逆序数.按定义,计算逆序数要通过n(n-1)/2此次比较,时间复杂度是O(n2).设计了一种新的方法,利用树状数组计算逆序数,时间复杂度降为O(nlog2(n)).主要思...

关 键 词:树状数组  逆序数  置换  算法  线段树

Algorithm of Inverse Number Based on Arborescence Array
Zhou Juan,Cao Yiqin,Xie Xin.Algorithm of Inverse Number Based on Arborescence Array[J].Journal of East China Jiaotong University,2011,28(2):45-49.
Authors:Zhou Juan  Cao Yiqin  Xie Xin
Institution:1.School of Software;2.School of Information Engineering,East China Jiaotong University,Nanchang 330013,China)
Abstract:Suppose there is a permutation of a1],a2],…,an] that is constituted by n elements.If ij and a i]a j],then(ai],aj]) is called an inverted sequence pair.The number of inverted sequence in a permutation is called inverse number of a permutation.According to the definition,the caculation of inverse number must be compared with n(n-1)/2,and the time complexity is O(n2).A new method is devised to calculate the reverse numble by arborescence array and reduce the time complexity to O(nlog2(n)).The principal idea of this method is to place elements into arborescence array in descending order.With regard to each element,since the previ-ous number which is bigger and being worked out at reverse number ti],when taking advantage of the architec-tural feature of arborescence array,it will come to ti] by the time complexity of O(log2(n)) and finally reach the total reverse number as ∑ti].
Keywords:arborescence array  inverse number  permutation  algorithm  segment tree
本文献已被 CNKI 维普 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号