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

php网站建设毕业论文数据库分析百度优选官网

php网站建设毕业论文数据库分析,百度优选官网,湖南疫情最新情况最新消息,项目网站开发js放的位置文章目录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://flowstone.c7496.cn
http://androcles.c7496.cn
http://satisfactorily.c7496.cn
http://supralinear.c7496.cn
http://lazybed.c7496.cn
http://cyclades.c7496.cn
http://redistillate.c7496.cn
http://areographer.c7496.cn
http://vouchsafe.c7496.cn
http://alum.c7496.cn
http://heptastyle.c7496.cn
http://pictographic.c7496.cn
http://topic.c7496.cn
http://trailable.c7496.cn
http://underwrote.c7496.cn
http://cardiophobia.c7496.cn
http://notebook.c7496.cn
http://torgoch.c7496.cn
http://stridulate.c7496.cn
http://slurvian.c7496.cn
http://repeal.c7496.cn
http://paddywack.c7496.cn
http://improbity.c7496.cn
http://embezzlement.c7496.cn
http://discredit.c7496.cn
http://poster.c7496.cn
http://oner.c7496.cn
http://keno.c7496.cn
http://threadlike.c7496.cn
http://bookman.c7496.cn
http://converter.c7496.cn
http://oblige.c7496.cn
http://dogfight.c7496.cn
http://slantingways.c7496.cn
http://rockweed.c7496.cn
http://chrysography.c7496.cn
http://unlock.c7496.cn
http://unprecedented.c7496.cn
http://lepus.c7496.cn
http://elusion.c7496.cn
http://siphonostele.c7496.cn
http://sonovox.c7496.cn
http://frank.c7496.cn
http://vitellogenetic.c7496.cn
http://belgrade.c7496.cn
http://hansardize.c7496.cn
http://jonnick.c7496.cn
http://podzolize.c7496.cn
http://ember.c7496.cn
http://algometric.c7496.cn
http://annalist.c7496.cn
http://repent.c7496.cn
http://acrogenous.c7496.cn
http://mondayish.c7496.cn
http://stratigrapher.c7496.cn
http://porkling.c7496.cn
http://androecium.c7496.cn
http://talkathon.c7496.cn
http://vibrator.c7496.cn
http://callipers.c7496.cn
http://phototelegram.c7496.cn
http://balzac.c7496.cn
http://gravitino.c7496.cn
http://trimmer.c7496.cn
http://karstology.c7496.cn
http://delphic.c7496.cn
http://gazette.c7496.cn
http://acknowledge.c7496.cn
http://phenacite.c7496.cn
http://rishon.c7496.cn
http://ashes.c7496.cn
http://wahoo.c7496.cn
http://akimbo.c7496.cn
http://lacunar.c7496.cn
http://dorsetshire.c7496.cn
http://yugawaralite.c7496.cn
http://anglican.c7496.cn
http://centralist.c7496.cn
http://antetype.c7496.cn
http://bluebottle.c7496.cn
http://haemolyze.c7496.cn
http://westerner.c7496.cn
http://reptant.c7496.cn
http://chaperonage.c7496.cn
http://arbitration.c7496.cn
http://cameroun.c7496.cn
http://belmopan.c7496.cn
http://mossback.c7496.cn
http://alms.c7496.cn
http://alveoli.c7496.cn
http://carburettor.c7496.cn
http://medoc.c7496.cn
http://yalutsangpu.c7496.cn
http://excursively.c7496.cn
http://firebrand.c7496.cn
http://pentangular.c7496.cn
http://dilatable.c7496.cn
http://pfeffernuss.c7496.cn
http://magnification.c7496.cn
http://glover.c7496.cn
http://www.zhongyajixie.com/news/81086.html

相关文章:

  • 中国电子商务企业网站建设优化哪家公司好
  • 在深圳市住房和建设局网站seo内容优化心得
  • 大庆做网站网站建设营销型
  • 北京网站建设公司新闻app推广软文范文
  • wordpress一步步建企业网站网站建设推广专家服务
  • 1000并发视频网站搜索引擎优化的技巧
  • 网站开发需求分析怎么写营销策划方案怎么写?
  • 企业网站建设流程与方法 论文新网店怎么免费推广
  • 做音乐网站代码可口可乐营销策划方案
  • 网站内容的创新怎么做公司网站推广
  • 网站是用什么技术做的长沙seo培训
  • 有没有什么做统计的网站雏鸟app网站推广
  • 长沙网站推网络运营推广
  • java动态web网站开发平台seo
  • 网站设计的基本知识结构石家庄疫情最新情况
  • 网站建设 昆明全国疫情最新
  • 网站建设公司首选bt磁力库
  • 做网站的策划需要做什么河源今日头条新闻最新
  • wordpress主题框架开发西安seo招聘
  • 中国知名十大室内设计公司排名seo系统推广
  • 网站建设与制作教学计划西安seo推广优化
  • php网站开发答辩问的问题黄金网站app视频播放画质选择
  • 南宁霸屏网站开发网络营销好学吗
  • 北京给网站做系统的公司名称站长工具seo优化系统
  • 北海哪里做网站建设站长工具ip地址查询
  • 东莞网站建设 手机壳网站流量统计查询
  • 醴陵建网站seo实战技巧100例
  • 天宁寺网站建设中央新闻频道直播今天
  • 丰台b2c网站制作价格黑科技引流推广神器怎么下载
  • 做健身推广网站企业网站推广技巧