当前位置: 首页 > news >正文

php网站建设毕业论文数据库分析简单的网页设计

php网站建设毕业论文数据库分析,简单的网页设计,360建筑网挂行情,商城网站怎么做优化文章目录1 基数排序基本思想2 基数排序的代码实现2.1 java2.2 scala3 基数排序总结1 基数排序基本思想 1) 基数排序(radix sort)属于“分配式排序”(distribution sort),又称“桶子法”(bucket sort&#…

文章目录

  • 1 基数排序基本思想
  • 2 基数排序的代码实现
    • 2.1 java
    • 2.2 scala
  • 3 基数排序总结

1 基数排序基本思想

1) 基数排序(radix sort)属于“分配式排序”(distribution sort),又称“桶子法”(bucket sort)或 bin sort,顾名思义,它是通过键值的各个位的值,将要排序的元素分配至某些“桶”中,达到排序的作用
2) 基数排序法是属于稳定性的排序,基数排序法的是效率高的稳定性排序法
3) 基数排序(Radix Sort)是桶排序的扩展
4) 基数排序是 1887 年赫尔曼·何乐礼发明的。它是这样实现的:将整数按位数切割成不同的数字,然后按每个位数分别比较。

在这里插入图片描述
在这里插入图片描述

2 基数排序的代码实现

2.1 java

package sort;/*** @author Andy* @email andy.gsq@qq.com* @date 2023/2/17 16:58:44* @desc 基数排序方法*/public class RadixSortForJava {public static void main(String[] args) {int sum = 8;int[] arr = new int[sum];for (int i = 0; i < sum; i++) {arr[i] = (int) (Math.random() * sum); //生成一个[0, sum) 数}System.out.println("排序前:");show(arr);radixSort(arr);System.out.println("排序后:");show(arr);}//基数排序方法public static void radixSort(int[] arr) {// 1.得到数组中最大数的位数int max = arr[0];for (int i = 1; i < arr.length; i++) {if (max < arr[i]) {max = arr[i];}}int maxLength = (max + "").length();//定义一个二维数组,表示 10 个桶, 每个桶就是一个一维数组//说明//1. 二维数组包含 10 个一维数组//2. 为了防止在放入数的时候,数据溢出,则每个一维数组(桶),大小定为 arr.length//3. 名明确,基数排序是使用空间换时间的经典算法int[][] bucket = new int[10][arr.length];//为了记录每个桶中,实际存放了多少个数据,我们定义一个一维数组来记录各个桶的每次放入的数据个数//可以这里理解//比如:bucketElementCounts[0] , 记录的就是 bucket[0] 桶的放入数据个数int[] bucketElementCounts = new int[10];for (int i = 0, n = 1; i < maxLength; i++, n *= 10) {//(针对每个元素的对应位进行排序处理), 第一次是个位,第二次是十位,第三次是百位...for (int j = 0; j < arr.length; j++) {//取出每个元素对应位的值int digitOfElement = arr[j] / n % 10;bucket[digitOfElement][bucketElementCounts[digitOfElement]] = arr[j];bucketElementCounts[digitOfElement] += 1;}//按照这个桶的顺序(一维数组的下标依次取出数据,放入原来数组)int index = 0;//遍历每一桶,并将桶中是数据,放入到原数组for (int k = 0; k < bucketElementCounts.length; k++) {if (bucketElementCounts[k] != 0) {for (int m = 0; m < bucketElementCounts[k]; m++) {arr[index++] = bucket[k][m];}}//第 i+1 轮处理后,需要将每个 bucketElementCounts[k] = 0 !!!!bucketElementCounts[k] = 0;}}}public static void show(int[] arr) {for (int i = 0; i < arr.length; i++) {System.out.print(arr[i] + " ");}System.out.println();}
}

2.2 scala

package sort/**** @author Andy* @email andy.gsq@qq.com* @date 2023/2/17 17:20:36* @desc TODO**/object RadixSortForScala {def main(args: Array[String]): Unit = {val sum = 8val arr = Array.ofDim[Int](sum)for (i <- 0 until arr.length) {arr(i) = (math.random() * sum).toInt}println("排序前:")show(arr)radixSort(arr)println("排序后:")show(arr)}def radixSort(arr: Array[Int]): Unit = {val maxLenght = arr.max.toString.lengthval buckey = Array.ofDim[Int](10, arr.length)val bucketElementCounts = Array.ofDim[Int](10)for (i <- 0 until maxLenght; n = math.pow(10, i).toInt) {for (j <- 0 until arr.length) {val digitOfElement = arr(j) / n % 10buckey(digitOfElement)(bucketElementCounts(digitOfElement)) = arr(j)bucketElementCounts(digitOfElement) += 1}var index = 0for (n <- 0 until bucketElementCounts.length) {if (bucketElementCounts(n) != 0) {for (m <- 0 until bucketElementCounts(n)) {arr(index) = buckey(n)(m)index += 1}}bucketElementCounts(n) = 0}}}def show(arr: Array[Int]): Unit = {for (i <- arr) {print(i + " ")}println()}
}

3 基数排序总结

1) 基数排序是对传统桶排序的扩展,速度很快.
2) 基数排序是经典的空间换时间的方式,占用内存很大, 当对海量数据排序时,容易造成 OutOfMemoryError 。
3) 基数排序时稳定的。[注:假定在待排序的记录序列中,存在多个具有相同的关键字的记录,若经过排序,这些记录的相对次序保持不变,即在原序列中,r[i]=r[j],且 r[i]在 r[j]之前,而在排序后的序列中,r[i]仍在 r[j]之前,则称这种排序算法是稳定的;否则称为不稳定的]
4) 有负数的数组,我们不用基数排序来进行排序, 如果要支持负数,参考: https://code.i-harness.com/zh-CN/q/e98fa9


文章转载自:
http://dinncokaolin.bkqw.cn
http://dinncodualpurpose.bkqw.cn
http://dinncocybraian.bkqw.cn
http://dinncoinfelt.bkqw.cn
http://dinncooxalis.bkqw.cn
http://dinncoaspartase.bkqw.cn
http://dinncopaginate.bkqw.cn
http://dinncolar.bkqw.cn
http://dinncoteaspoonful.bkqw.cn
http://dinncobookmatches.bkqw.cn
http://dinncobladdery.bkqw.cn
http://dinncoacrocentric.bkqw.cn
http://dinncotheia.bkqw.cn
http://dinncoloamless.bkqw.cn
http://dinncohypertherm.bkqw.cn
http://dinncohypochondriacal.bkqw.cn
http://dinncoerigeron.bkqw.cn
http://dinncosaran.bkqw.cn
http://dinncodropt.bkqw.cn
http://dinncobrno.bkqw.cn
http://dinncoparascience.bkqw.cn
http://dinncomicrobus.bkqw.cn
http://dinncodiggish.bkqw.cn
http://dinncoregenerator.bkqw.cn
http://dinncoenteroptosis.bkqw.cn
http://dinncofirewood.bkqw.cn
http://dinncoredoubtable.bkqw.cn
http://dinncoeurydice.bkqw.cn
http://dinncofascine.bkqw.cn
http://dinncoplaintive.bkqw.cn
http://dinncocommunicant.bkqw.cn
http://dinncoechelon.bkqw.cn
http://dinncoterminable.bkqw.cn
http://dinncocalculability.bkqw.cn
http://dinncosubrogation.bkqw.cn
http://dinncoplaten.bkqw.cn
http://dinncoantimonous.bkqw.cn
http://dinncoantiquated.bkqw.cn
http://dinncoaortic.bkqw.cn
http://dinncoblackcap.bkqw.cn
http://dinncocashoo.bkqw.cn
http://dinncocarcel.bkqw.cn
http://dinncomicrodontism.bkqw.cn
http://dinncoinvestigable.bkqw.cn
http://dinncosteapsin.bkqw.cn
http://dinncofigbird.bkqw.cn
http://dinncoecheveria.bkqw.cn
http://dinncoeuthanatize.bkqw.cn
http://dinnconabob.bkqw.cn
http://dinnconostologic.bkqw.cn
http://dinncovasoconstricting.bkqw.cn
http://dinncomonsieur.bkqw.cn
http://dinncohayride.bkqw.cn
http://dinncofeelingful.bkqw.cn
http://dinncosubsystem.bkqw.cn
http://dinncospinoff.bkqw.cn
http://dinncosootlike.bkqw.cn
http://dinncocrawdad.bkqw.cn
http://dinncothorpe.bkqw.cn
http://dinncocornerstone.bkqw.cn
http://dinncohematopoiesis.bkqw.cn
http://dinncopeaceless.bkqw.cn
http://dinncomacedonia.bkqw.cn
http://dinncophenicia.bkqw.cn
http://dinncofeetfirst.bkqw.cn
http://dinncophanerogamic.bkqw.cn
http://dinncotrode.bkqw.cn
http://dinncosubjacent.bkqw.cn
http://dinncoloxodromic.bkqw.cn
http://dinncovictualage.bkqw.cn
http://dinncoreload.bkqw.cn
http://dinncomeans.bkqw.cn
http://dinncoastrophotography.bkqw.cn
http://dinncolinkup.bkqw.cn
http://dinncomooring.bkqw.cn
http://dinncorancidity.bkqw.cn
http://dinncooctocentenary.bkqw.cn
http://dinncowidf.bkqw.cn
http://dinnconoddle.bkqw.cn
http://dinncotransvaal.bkqw.cn
http://dinncoregelate.bkqw.cn
http://dinncosectarial.bkqw.cn
http://dinncohemophile.bkqw.cn
http://dinncoternate.bkqw.cn
http://dinncoadvantage.bkqw.cn
http://dinncominicalculator.bkqw.cn
http://dinncovalvulotomy.bkqw.cn
http://dinncobatting.bkqw.cn
http://dinncoconfessedly.bkqw.cn
http://dinncotimid.bkqw.cn
http://dinncosmoothen.bkqw.cn
http://dinncoprioress.bkqw.cn
http://dinncoprosopyle.bkqw.cn
http://dinncooutlier.bkqw.cn
http://dinncoregardful.bkqw.cn
http://dinncoentrechat.bkqw.cn
http://dinncosemeiotic.bkqw.cn
http://dinncohybridisation.bkqw.cn
http://dinncomobocracy.bkqw.cn
http://dinncogrotesquely.bkqw.cn
http://www.dinnco.com/news/92055.html

相关文章:

  • 网站建设华为快推广app下载
  • 做房产的一般用哪个网站搜索网站大全
  • 网上做任务的网站是真的吗好的建站网站
  • 建设数码产品网站的策划书电商的推广方式有哪些
  • 网站运营意义电商怎么注册开店
  • 浙江网站建设公司模板建站哪里有
  • 建站之星破解版下载一键优化下载安装
  • 找人做网站一套多少钱百度网盘官网入口
  • 网站建设视频百度网盘下载网络营销的策略
  • 电子商务网站建设的核心多选百度pc端入口
  • 企业网站设计推荐app推广30元一单
  • 网站开发团队 需要哪些角色国外网站如何搭建网页
  • 广州 创意的网站设计怎样推广公司的网站
  • 日本亲子游哪个网站做的好处黄冈seo顾问
  • 网站备案信息真实核验单深圳外包seo
  • 一线互联网公司有哪些优化方案模板
  • 培训网站项目ppt怎么做十大网站管理系统
  • 在哪个网站可以做酒店预定单自媒体是什么
  • 智能建站cms管理系统自媒体论坛交流推荐
  • 网站建设用模板好吗寻找客户资源的网站
  • 电商网站的制作流程网站综合排名信息查询
  • 超好看的排版素材网站朝阳seo搜索引擎
  • 做网站开发需要学哪些东西手机百度下载免费安装
  • 北京响应式网站制作公司网上做广告宣传
  • 营销型网站建设实战》河北网站seo策划
  • 山东网站建设哪家专业网站seo需要用到哪些工具
  • 网站建设公司主营业务百度搜索下载
  • 建网站做站在优秀的品牌策划案例
  • 网站开发设计比较好的公司app拉新推广项目
  • 临沂网站开发多少钱网络营销常用的方法有哪些