scala数据结构和算法-09-基于插入排序的基数排序

本教程提供了一系列关于Kubernetes(K8s)的部署方法及资源管理配置的视频课程,涵盖minikube、kubeadm等多种部署方式,并详细介绍了configmap、pod、service等核心K8s资源的概念和使用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967

课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。

腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518

第二个视频发布  https://edu.csdn.net/course/detail/27109

腾讯课堂连接地址https://ke.qq.com/course/484107?tuin=ba64518

介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。

第三个视频发布:https://edu.csdn.net/course/detail/27574

详细介绍helm命令,学习helm chart语法,编写helm chart。深入分析各项目源码,学习编写helm插件
————————————————------------------------------------------------------------------------------------------------------------------

基数排序是另外一种比较有特色的排序方式,它是怎么排序的呢?我们可以按照下面的一组数字做出说明:12、 104、 13、 7、 9

    (1)按个位数排序是12、13、104、7、9

    (2)再根据十位排序104、7、9、12、13

    (3)再根据百位排序7、9、12、13、104

 

package data

import scala.collection.mutable.ListBuffer
import scala.collection.mutable.ListBuffer

object RadixSort {
  def insertSort(source:ListBuffer[Int],radixSource:ListBuffer[Int]):ListBuffer[Int]={
    for(i<-1 until radixSource.length){
      for(j<-(1 to i).reverse){
        val current=radixSource(j);
        val prev=radixSource(j-1);
        if(current<prev){
          radixSource(j-1)=current;
          radixSource(j)=prev;
          val tmp=source(j-1)
          source(j-1)=source(j);
          source(j)=tmp;
        }
      }
    }
    source
  }
  def getMaxLength(source:ListBuffer[Int])={
    var maxCount=0;
    for(i<-0 until source.length){
      var tmp=source(i)
      var count=0
      while(tmp/10>0){
        count+=1
        tmp=tmp/10
      }
      count+=1
      if(count>maxCount){
        maxCount=count;
      }
      
    }
    maxCount
  }
  def radixSort(source:ListBuffer[Int])={
    val maxCount=getMaxLength(source);
    for(i<-1 to maxCount){
      var radixSource=ListBuffer[Int]()
      for(j<-0 until source.length){
        var tmp=source(j)
        var k=i;
        while(k-1>0){
          tmp=tmp/10
          k-=1
        }
        radixSource.append(tmp%10)
      }
      insertSort(source,radixSource)
    }
    source
  }
  def main(args: Array[String]): Unit = {
    val source=ListBuffer(33,12,21,90,101,8,10,67,40,109,121,5,11111)
    println(getMaxLength(source));
    println(radixSort(source).mkString(","))
  }
}

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hxpjava1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值