这是什么排序算法的名称? [英] What is the name of this sorting algorithm?

查看:112
本文介绍了这是什么排序算法的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

for(int i=0; i<n-1; i++)
{
    for(int j=i+1; j<n; j++)
    {
        if(a[i] > a[j])
        {
            /* Swap a[i] and a[j] */
        }
    }
}

PS 给定一个算法的名称,人们可以很容易地找到相应和源$ C ​​$ C。但是,我觉得很难做到,反之亦然:D

P.S. Given the name of an algorithm, one can easily find relevent source code. But I find it hard to do the vice-versa :D

修改哦!如果是冒泡排序,那么什么是这个名字:

Edit Oh! If that is bubble sort, then what is the name of this:

for(int i=0; i<n; i++)
{
    for(int j=0; j<n-1; j++)
    {
        if(a[j] > a[j+1])
        {
            /* Swap a[j] and a[j+1] */
        }
    }
}

我认为这第二个泡沫的更小的元素,所以我想的这个的竟是冒泡排序。如果第一个是冒泡排序,有什么的第二个名字?

I thought this second one "bubbles" the smaller elements up, so I thought this was actually bubble sort. If the first one is bubble sort, what's the name of the second one?

推荐答案

首先是选择排序,你添加第二个是冒泡排序!

First is the Selection Sort and the second one you added is Bubble sort!

这篇关于这是什么排序算法的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆