Java常用排序算法之堆排序

Java常用排序算法 阅读详情
public class HeapSort {
    static final int SIZE = 10;

    public static void main(String[] args) {
        int arr[] = new int[SIZE];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (int) (Math.random() * 100);
        }
        System.out.println("排序前的数组:");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        heapSort(arr, SIZE);
        System.out.println("堆排序后的数组:");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }

    private static void heapSort(int arr[], int n) {
        int i, j, h, k;
        int t;//定义交换数组是的中间过渡变量

        //输出原数据构成的堆
        for (i = n / 2 - 1; i >= 0; i--) {
            while (2 * i + 1 < n) {// 第i个结点有子树(至少有左子树)
                j = 2 * i + 1;// j为i结点左子树索引
                if ((j + 1) < n) {// 判断第i结点是否有右子树
                    if (arr[j] < arr[j + 1]) {
                        j++;// 如果有右子树并且右子树大于左子树,则比较结点与其右子树,j++即右子树索引
                    }
                } // 如果没有右子树或者右子树小于等于左子树则比较结点与其左子树大小
                if (arr[i] < arr[j]) {
                    t = arr[i];
                    arr[i] = arr[j];
                    arr[j] = t;
                    i = j;// 由于此时堆被破坏,需要重新调整结点j,将j赋给i
                } else {
                    break;
                }
            }
        }
        System.out.print("原数据构成的堆为:");
        for (h = 0; h < n; h++) {
            System.out.print(" " + arr[h]);
        }
        System.out.println();



        //输出每一步剩下的(i--)个数据构成的堆和已排序的数据
        for (i = n - 1; i > 0; i--) {
            t = arr[0];
            arr[0] = arr[i];// 依次arr[0]与arr[n-1]、arr[n-2]、arr[n-3]...交换
            arr[i] = t;
            k = 0;
            while (2 * k + 1 < i) {// 上面交换后,待排序的数组长度为i,判断第k个结点有子树(至少有左子树)
                                        //从第k=0个结点开始,只比较改变破坏的的部分,不改变未破坏的部分
                j = 2 * k + 1;// 第k个结点左子树索引定义为j
                if ((j + 1) < i) {// 判断是否有右子树
                    if (arr[j] < arr[j + 1]) {
                        j++;// 如果有右子树并且右子树大于左子树,则比较结点与其右子树,j++即右子树索引
                    }
                } // 如果没有右子树或者右子树小于等于左子树则比较结点与其左子树大小
                if (arr[k] < arr[j]) {
                    t = arr[k];
                    arr[k] = arr[j];
                    arr[j] = t;
                    k = j;// 由于此时堆被破坏,需要重新调整结点j,将j赋给k
                } else {
                    break;
                }
            }
            System.out.print("第" + (n - i) + "步排序结果:");
            for (h = 0; h < n; h++) {
                System.out.print(" " + arr[h]);
            }
            System.out.println();
        }
    }
}

输出:

排序前的数组:
87 68 34 70 29 88 83 33 76 29 
原数据构成的堆为: 88 76 87 70 29 34 83 33 68 29
第1步排序结果: 87 76 83 70 29 34 29 33 68 88
第2步排序结果: 83 76 68 70 29 34 29 33 87 88
第3步排序结果: 76 70 68 33 29 34 29 83 87 88
第4步排序结果: 70 33 68 29 29 34 76 83 87 88
第5步排序结果: 68 33 34 29 29 70 76 83 87 88
第6步排序结果: 34 33 29 29 68 70 76 83 87 88
第7步排序结果: 33 29 29 34 68 70 76 83 87 88
第8步排序结果: 29 29 33 34 68 70 76 83 87 88
第9步排序结果: 29 29 33 34 68 70 76 83 87 88
堆排序后的数组:
29 29 33 34 68 70 76 83 87 88 
2024年游戏策划最新面试题及答案 1. **游戏策划**:负责游戏设计和开发的创意和技术过程。2. **主要职责**:设计游戏玩法、故事、角色、世界等。4. **游戏机制**:定义玩家如何与游戏世界互动的规则。13. **引人入胜的角色**:深入的背景故事、个性特征。3. **游戏平衡**:确保游戏公平、有趣且具有挑战性。7. **RPG特点**:角色发展、故事驱动、玩家选择。12. **关卡设计技巧**:挑战性、流动性、视觉引导。11. **游戏关卡设计**:创建游戏世界的不同阶段。5. **游戏循环**:玩家在游戏中重复的行为模式。 阅读详情

相关推荐

ESP32S3开发实战:从Vscode+IDF环境配置到OpenOCD单步调试全流程

本文详细介绍了ESP32S3开发环境的完整搭建流程,重点讲解如何在Vscode中配置ESP-IDF开发框架,并利用OpenOCD工具实现硬件单步调试。内容涵盖从环境准备、工程创建、代码烧录到高级调试技巧的全方位实战指南,旨在帮助开发者快速掌握ESP32S3的高效开发与调试方法。

weixin_29168813的博客 211

嵌入式笔试面试题(6)---排序及查找

1、就排序算法所用的辅助空间而言,堆排序,快速排序,归并排序的关系是 A.堆排序〈快速排序〈归并排序   B.堆排序〈 归并排序〈 快速排序C.堆排序〉归并排序〉快速排序    D.堆排序 &gt;  快速排序 &gt; 归并排序 E.以上答案都不对   2、编程题二分法(折半查找算法)#include&lt;stdio.h&gt;//int find(int aim,int data[],int...

xt18971492243的博客 1422

CentOS7安装openGauss5.0.2LTS版本

该文档要根据自己的实际情况调整ip地址。要根据自己的实际网卡调整。

superhanyubo的专栏 2579

大连理工大学数据结构与算法(复习题二)【图、查找、排序】

文章目录 数据结构与算法(习题) 第六章 图 第七章 查找 第八章 排序

心海非海_のBlog 4082

Nuclei漏洞扫描:从零到精通的Windows实战指南

本文详细介绍了Nuclei漏洞扫描工具在Windows平台上的安装与使用教程,从基础安装到高级实战技巧全面覆盖。通过具体案例展示如何利用Nuclei的模板库快速检测常见漏洞,并提供自定义POC开发指南,帮助安全从业者高效开展漏洞扫描工作。

weixin_28683689的博客 251

【AI赋能】Sora + CapCut 打造爆款短视频:从脚本到发布的自动化工作流

本文详细介绍了如何利用Sora、Grok和CapCut等AI工具构建自动化短视频生产工作流。通过结构化Prompt生成专业脚本,借助Sora将文字转化为高质量视频素材,并利用CapCut进行高效剪辑与合成,实现从创意到发布的十倍效率提升,助力个人及团队打造爆款内容。

g8f9d0s1a2的博客 500

数据结构复习题集(客观题)

一、选择题 在对N个元素进行排序时,基于比较的算法中,其“最坏时间复杂度”中最好的是: A、О(logN) B、О(N) C、О(NlogN) D、О(N2^22) 快速排序的时间复杂度最好是O(nlogn),平均也是O(nlogn),这种情况是轴枢恰好能把两侧的分开。 时间复杂度最差是O(N2),最差的情况选择的轴枢在数组最左侧或是最右侧 对一组数据{ 2,12,16,88,5,10 }进行排序,若前三趟排序结果如下: 第一趟排序结果:2,12,16,5,10,88 第二趟排序结果:2,12,5,10

生活即当下,技术让生活更精彩。 6902

C++ 程序稳定运行一段时间后异常中止?vc6 运行库的bug!!!

事件查看器提示:错误应用程序 xxxxxxx.exe,版本 0.0.0.0,错误模块 MSVCRTD.DLL,版本 6.0.9782.0,错误地址 0x00012b40。这是一个通信方面的软件,需要长期运行,在压力测试时,高负荷连续运行一定天数时必定崩溃,而且都是在msvcrtd.dll中崩溃。后来在dump文件中发现调用栈在是MSVCRTD.DLL模块,跟踪代码发现是在void * __cdecl _heap_alloc_dbg(        size_t nSize,        int nBloc

qingflying的专栏 2680

利用ArrayList对map进行按key(键)和按value (值) 排序

利用ArrayList对map进行按key(键)和按value (值) 排序 总感觉按照值得应该比较少,意义好像也不大,感觉还没有真正懂。 使用比较器 按key(键)排序 通过ArrayList将map.entrySet(),变成list 然后在类外写具体如何比较大小的方法compare(),最后调用 Collections.sort(list, new Comparator<Map.Entry<String, String>>() import java.util.*; pub

qq_41487251的博客 5309

高熵合金AlCoCrFeNi/金刚石摩擦案例代码

本文介绍金刚石与高熵合金AlCoCrFeNi摩擦的案例。 在之前的文章中,介绍过使用fix indent命令实现虚拟球的摩擦,本文介绍使用金刚石实体球实现高熵合金摩擦的方法。 主要的模拟过程如下: (1)基体建模 建使用原子替换法获得高熵合金初始模型,升温到3000K驰豫后,冷却至300K,获得平衡组织。 (2)摩擦球建模 在高熵合金平衡组织的模型中添加金刚石摩擦球,使用change_box命令扩大box尺寸,添加金刚石摩擦球,并设置混合力场。 (3)摩擦过程 摩擦球下压一定深度后,沿y方向进行摩擦,摩擦

lammps_jiayou的博客 2900

Transformer实战——Transformer自编码模型

自编码模型依赖于原始 Transformer 编码器,并且在解决分类问题时非常高效。除了 BERT 外,还有许多流行的自编码模型,在本节中,我们将一些除 BERT 外的自编码模型,这些模型的目标是通过优化预训练过程、增加层数或头数、改善数据质量、设计更好的目标函数等,来在下游任务上取得更好的表现。这些改进大致可以分为两个方面,更好的架构设计选择和预训练控制。

盼小辉丶的博客 9362

排序算法 | 快排、冒泡、堆排、归并、基数、递归、希尔、计数

本文为笔者学习排序算法时整理的学习笔记,包括刷过的练习题目。文中部分题解与图片摘自“牛客网”。因为知识点众多,后续会持续整理更新~

qq_44250700的博客 1万+

【Windows Server 2019】发布服务器 | 远程桌面服务的安装与配置 Ⅰ——理论,实验拓扑和安装基于RemoteAPP的RDS

博客介绍了Windows Server中远程桌面服务的理论,实验拓扑以及基于RemoteAPP的RDS安装。博文介绍了如何在Windows Server上部署发布服务器。

VMware, Windows, Linux, Cisco, Container, Kubernetes, Kali 6130

java常用排序算法之堆排序

JAVA常用排序算法之堆排序   算法的平均时间复杂度为O(n×log(n)) 实现的代码如下:   package com.beibei.risk.sort; /** * desc:堆排序算法,使用大根堆 * Created by zhai on 2017/9/7. */ public class HeadSort { public static void main(...

haha的博客 230

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

【常用排序算法】堆排序(Java实现)

第一次代码记录: public class HeapSort { public static void main(String[] args) { // 初始化一个序列 int[] array = {1, 3, 4, 5, 2, 6, 9, 7, -8, 0}; heapSort(array);

DChuan 298

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

Java数据结构_10.常用排序算法_堆排序

堆排序 原理:将数组转为完全二叉树再转为大顶堆,然后将根节点与叶子节点的最后一个值调换,找到最大值,将最大值取出,现在又变成一个完全二叉树,继续将这个完全二叉树转成大顶堆,以此类推,直至找到所有的最大值。 升序排序用大顶堆,降序排序用小顶堆 大顶堆:父节点总比两个子节点的权值要大 package com.paixu; import java.util.Arrays; public class HeapSort { public static void main(String[] args) {

郝穹的博客 221

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

常用排序算法(二)---优雅地用Java实现堆排序吧!!

关于堆排序 相信有很多博客都讲得很细很细了 堆排序的思路还是比较好理解的 也是面试经常考查的点 因此我觉得把堆排序给啃下来 然而 图解堆排序的博客很多 但是堆排序的代码实在是写得太复杂了 我一个菜鸡实在是很难理解 花费了一整个下午的时间 把堆排序的代码给整理出来了 附上详尽的注释 相信看着这份代码 对照着图解 很多就能把堆排序掌握下来啦! 以下附上代码:(可能不是想象的那么优雅 但力求简单易懂好吧!) package Aug; import java.util.Arrays; /** * 堆排序 *

fucccck_ly的博客 200

【Java常用排序算法】选择排序(简单选择排序、堆排序)

选择排序 Java 简单选择排序 堆排序

一个普本码农奋斗史 1464

【Java】八个常用的排序算法:插入排序、冒泡排序、选择排序、希尔排序 、快速排序、归并排序、堆排序和LST基数排序

这篇文章主要介绍了Java如何实现八个常用的排序算法:插入排序、冒泡排序、选择排序、希尔排序 、快速排序、归并排序、堆排序和LST基数排序,需要的朋友可以参考下 本文实现了八个常用的排序算法:插入排序、冒泡排序、选择排序、希尔排序 、快速排序、归并排序、堆排序和LST基数排序 首先是EightAlgorithms.java文件,代码如下: import java.util.Arr

小坚的技术博客 1150

【算法】Java实现常用排序算法一(冒泡排序、选择排序、插入排序、堆排序、快速排序)

常用算法插入排序冒泡排序选择排序 插入排序 冒泡排序 选择排序

TiramisuDP的博客 375

手写常用排序算法(插入,希尔,快排,选择,堆排序,归并,基数,桶排序),java实现

在排序算法的复习当中,有些算法还是比较难理解的,好在以前打下的基础,再次学习轻松很多,下面记录下手写常用的排序算法。如标题所示。每个排序加了一些便于我自己理解的短语,希望大家在看这边文章时,已经对排序算法有所理解。 直接插入排序的性能分析: 1. 最好情况:O(n) 2. 平均情况:O(n^2) 3. 最坏情况:O(n^2) 空间复杂度:O(1) 稳定性:稳定(相同元素的相对位置不会...

LiangCJP的博客 1118

两种常用的选择排序算法--简单选择排序、堆排序

两种常用的选择排序算法--简单选择排序、堆排序

TimeTDIT的博客 1138

【数据结构】之排序算法综合篇

博主声明: 转载请在开头附加本文链接及作者信息,并标记为转载。本文由博主威威喵原创,请多支持与指教。 本文首发于此 博主:威威喵|博客主页:https://blog.youkuaiyun.com/smile_running 数据结构课程的内容基本忘光了,所以又拾起数据结构与算法的书本,重新学习了一边排序算法的原理和实现,在经过几个晚上的努力,终于把这几种排序算法给搞明白了,下...

你若盛开,蜜蜂自来 7663

Java常用的数组排序算法(面试宝典)

这段时间有些忙,今天空闲出来给大家分享下Java中常用的数组排序算,有冒泡排序、快速排序、选择排序、插入排序、希尔算法、并归排序算法、堆排序算法,以上排序算法中,前面几种相对后面的比较容易理解一些。下面为大家一一介绍,写的不好,大佬绕过。 1、冒泡排序 冒泡排序是一种简单的排序算法。它重复地走访过要排序的数列,一次比较两个元素,如果他们的顺序错误就把他们交换过来。走访数列的工作是重复地进行...

坐看云起时_雨宣 8260

堆排序--java实现

package nomal; public class HeapSort { public static void main(String[] args) { int[] arr = {23,3, 54, 12, 7, 99, 88, 65}; heapSort(arr); for (int i : arr) { System.out.print(i + " "); } } private.

282
上一篇: Java常用排序算法之快速排序
下一篇: Java常用排序算法之合并排序
詹詹自喜KING
博客等级 码龄11年 40粉丝 64原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值