惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy International News Feed
Martin Fowler
Martin Fowler
D
Docker
Y
Y Combinator Blog
云风的 BLOG
云风的 BLOG
U
Unit 42
T
Tailwind CSS Blog
J
Java Code Geeks
G
Google Developers Blog
MongoDB | Blog
MongoDB | Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
美团技术团队
F
Fortinet All Blogs
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Recorded Future
Recorded Future
N
Netflix TechBlog - Medium
Google DeepMind News
Google DeepMind News
Hacker News: Ask HN
Hacker News: Ask HN
L
LINUX DO - 最新话题
Microsoft Security Blog
Microsoft Security Blog
N
News and Events Feed by Topic
I
Intezer
TaoSecurity Blog
TaoSecurity Blog
NISL@THU
NISL@THU
小众软件
小众软件
博客园 - 聂微东
博客园 - Franky
有赞技术团队
有赞技术团队
P
Palo Alto Networks Blog
爱范儿
爱范儿
H
Hacker News: Front Page
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
P
Proofpoint News Feed
I
InfoQ
Google DeepMind News
Google DeepMind News
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News
H
Heimdal Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位

博客园 - kenty06

LINQ 查询Select LINQ之DataContext 数据上下文 Dedecms57 分页 dede:pagelist 说明 window service服务安装错误 命名空间基础知识 - kenty06 - 博客园 C#简单类型转换说明 建立全文索引以及使用 Asp.net中防止用户多次登录的方法 VSS使用手册 开启全文索引 extJS初学小问题之js文件编码 - kenty06 - 博客园 VS2008加载包失败的解决方法 VS2005快捷键(转) 关于 odbc OdbcParameter参数问题 - kenty06 在 dotnet环境下使用 文件dsn - kenty06 关于枚举enum的tostring方法不能重写的一种替代方案 asp.net 2.0 学习点滴推荐(001) - kenty06 aspx页面事件顺序 - kenty06 - 博客园 C#中的default
希尔排序
kenty06 · 2010-02-05 · via 博客园 - kenty06

希尔排序

2010-02-05 07:01  kenty06  阅读(184)  评论()    收藏  举报

/// <summary>
    /// 希尔排序
    /// </summary>
    class ArraySh
    {
        private int[] theArray;
        private int nElems;
        public ArraySh(int max)
        {
            theArray = new int[max];
            nElems = 0;
        }
        public void Insert(int value)
        {
            theArray[nElems++] = value;
        }
        public void ShellSort()
        {
            int inner, outer;
            int temp;

            int h = 1;//计算间隔
            while (h <= nElems / 3)
                h = h * 3 + 1;

            while (h > 0)
            {
                for (outer = h; outer < nElems; outer++)
                {
                    temp = theArray[outer];
                    inner = outer;
                    while (inner > h - 1 && theArray[inner - h] >= temp)
                    {
                        //交换间隔值
                        theArray[inner] = theArray[inner - h];
                        inner -= h;
                    }
                    theArray[inner] = temp;
                }
                h = (h - 1) / 3;
            }
        }
    }