• 欢迎访问废江's博客 QQ群
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏本站吧

Shell Sort

AOJ 站点默认 1年前 (2020-04-04) 662次浏览 已收录 76个评论
文章目录[隐藏]

Question

FpUhq.png
Sample Input 1
5
5
1
4
3
2
Sample Output 1
2
4 1
3
1
2
3
4
5
Sample Input 2
3
3
2
1
Sample Output 2
1
1
3
1
2
3
0

Meaning

题目的要求是用希尔排序给一组数据排序,除了输出排列过后的数据。还需要输出增量序列以及排序次数。题目要求使用指定的增量序列,即1,4,13,40,121等等,该增量序列也是效率极高的一个,算法的时间复杂度维持在1.25。

Solution

如果理解了插入排序的话,这题应该不难。希尔排序就是给插入排序中的增量1换成指定的数,然后进行多次插入排序(当然最后肯定需要进行一次增量1的排序,以保证数据的有序性)。或许会疑惑,这样不是时间耗得更多 吗?,其实不然,因为插入排序法可以高速处理顺序比较整齐的数据,希尔排序就是充分发挥了这一特长的高速算法!还是回到解题步骤吧:在基础的插入排序函数中带入一个参数增量g,外层套一个增量序列G,每次给g=G[i]赋值,基础的插入排序算法中稍微修改一下就ok,给之前的加1,改成加g。

Coding

Summary


希尔排序,我在之前写代码时候在更改后的插入排序函数中原本是给i直接赋值给j,然后去判断a[j-1]和当前值tmp的大小,但是题目中前几个可以ac,后面就不可以了,喜欢深究的小伙伴可以告诉我这是为什么。
原来的:

修改后:

入坑笔记:大数组需要定义在main函数外面!


希尔排序和插入排序的比较:


个人博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Shell Sort
喜欢 (0)
[]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到
(76)个小伙伴在吐槽
  1. It¦s actually a great and useful piece of information. I¦m glad that you shared this useful information with us. Please stay us up to date like this. Thanks for sharing.
    匿名2021-04-13 06:24 (1天前)回复 Windows 10 | Chrome 62.0.3202.94
  2. viagra online canadian pharmacy buying viagra online without prescription viagra without a prescription
    匿名2021-04-12 10:27 (2天前)回复 Windows 10 | Chrome 83.0.4089.0
  3. how much will generic viagra cost buying viagra online without prescription viagra online no prescription
    匿名2021-04-11 06:53 (3天前)回复 Windows 10 | Chrome 83.0.4103.34
  4. cialis pills online: order erectile dysfunction pills erectile dysfunction pills
    匿名2021-04-09 12:55 (5天前)回复 Windows 10 | Chrome 83.0.4103.61
  5. [url=https://thesisacloud.com/]thesisacloud.com[/url] doctoral thesis thesisacloud.com phd thesis writing service
    匿名2021-04-08 12:36 (6天前)回复 Windows 8.1 | Chrome 63.0.3239.84
  6. plaquenil sid effects [url=https://ushydroxychloroquine.com/]generic plaquenil coupon [/url] is it safe to take plaquenil plaquenil how long to get out of system
    匿名2021-04-08 11:03 (6天前)回复 Windows 10 | Chrome 83.0.4103.61
  7. paxil max dosage [url=https://paroxetine10.com/]order paxil online cheap [/url] over the counter substitute for paxil how to buy paxil online
    匿名2021-04-07 09:23 (7天前)回复 Windows 10 | Chrome 83.0.4103.61
  8. paxil warnings buy paxil online paxil and drinking alcohol side effects what are the long term effects of paxil
    匿名2021-04-07 03:43 (1周前)回复 Windows 7 | Chrome 83.0.4103.61
  9. india pharmacy: online medications from india india pharmacy drugs
    匿名2021-04-07 01:27 (1周前)回复 Windows 7 | Chrome 83.0.4102.0
  10. metformin and cancer metformin 250 mg does metformin make you tired how much can metformin lower blood sugar
    匿名2021-04-05 16:48 回复 Windows 10 | Chrome 83.0.4103.44
  11. neurontin manufacturer gabapentin pharmacy can i take baclofen with neurontin gabapentin when does it start working
    匿名2021-04-04 06:50 回复 Windows 7 | Chrome 83.0.4102.0
  12. difluprednate vs prednisolone prednisolone sod prednisolone 15mg/5ml dosage by weight what is pyrdium and can i use it with prednisolone
    匿名2021-04-02 21:10 回复 Windows 10 | Chrome 83.0.4103.14
  13. myambutol online: buy vantin buy ampicillin online
    匿名2021-04-02 19:20 回复 Windows 8.1 | Chrome 83.0.4103.44
  14. propecia alone results propecia tablets price in india propecia hair loss after stopping how long propecia regrowth
    匿名2021-04-01 10:41 回复 Windows 10 | Chrome 83.0.4093.3
  15. generic propecia 1mg [url=https://finasteridehq.com/]propecia singapore price [/url] does propecia halt muscle development when did brain fog go away propecia hep
    匿名2021-03-31 13:34 回复 Windows 8.1 | Chrome 83.0.4103.44
  16. [url=https://kloviagrli.com/]viagra discounts[/url] [url=https://vigedon.com/]cheapest viagra[/url] [url=https://llecialisjaw.com/]cialis dosage[/url] [url=https://jwcialislrt.com/]cheap cialis canada[/url] [url=https://jecialisbn.com/]cialis price costco[/url]
    匿名2021-03-30 01:19 回复 未知操作系统 | Firefox浏览器 44.1
  17. [url=http://essaywriteris.com/]professional college essay writers[/url] write my essays write my essay discount code online essay writers
    匿名2021-03-28 00:12 回复 Windows XP | Firefox浏览器 52.0
  18. [url=https://ljcialishe.com/]definition cialis[/url] [url=https://cialisvja.com/]cialis generic release date[/url] [url=https://viagraonlinejc.com/]mail order viagra[/url] [url=https://viagratx.com/]viagra not working anymore[/url] [url=https://buycialisxz.com/]buy cialis online cheap[/url]
    匿名2021-03-27 18:35 回复 未知操作系统 | Firefox浏览器 43.0
  19. http://gabapentinst.com/# drug neurontin
    匿名2021-03-26 15:18 回复 Windows 8.1 | Chrome 83.0.4103.61
  20. why take synthroid synthroid brand name is armour thyroid better than synthroid levothyroxine vs. synthroid which is better
    匿名2021-03-26 05:31 回复 Windows 7 | Chrome 83.0.4103.61
  21. [url=https://dissertationahelp.com/]help dissertation[/url] dissertation online dissertation abstracts online dissertation writing service
    匿名2021-03-25 21:54 回复 Windows 7 | Chrome 61.0.3163.100
  22. fluconazole diflucan diflucan prescription can you buy diflucan at walgreens how much does diflucan cost without insurance
    匿名2021-03-24 21:40 回复 Windows 10 | Chrome 83.0.4087.0
  23. synthroid recall [url=http://levothyroxine50.com/]synthroid 0.05 mcg [/url] can i drink coffee after taking synthroid what is synthroid?
    匿名2021-03-24 13:12 回复 Windows 10 | Chrome 83.0.4103.34
  24. ed pills without a doctor prescription cheap ed pills from canada buy ed pills
    匿名2021-03-24 11:13 回复 Windows 7 | Chrome 83.0.4103.61
  25. [url=https://thesisacloud.com/]thesis proposal help[/url] help writing a thesis statement thesis proposals thesis service
    匿名2021-03-23 19:47 回复 Windows Vista | Firefox浏览器 34.1
  26. priligy tablet dapoxetine medicine price in india dapoxetine buy online in india how to use priligy
    匿名2021-03-23 13:46 回复 Windows 10 | Chrome 83.0.4103.61
  27. buy cheap prescription drugs online cheap ed pills usa cheap ed pills from canada
    匿名2021-03-23 08:02 回复 Windows 10 | Chrome 83.0.4100.3
  28. synergi dapoxetine [url=https://dapoxetine30.com/]dapoxetine prescription usa [/url] super p force cialis with dapoxetine review how long does the effect of dapoxetine last
    匿名2021-03-22 18:52 回复 Windows 10 | Chrome 83.0.4103.24
  29. dosage prednisolone cats prednisolone brand name uk prednisolone acetate eye drops uses how long is unopened prednisolone acetate liquid 1% good
    匿名2021-03-22 05:26 回复 Windows 10 | Chrome 83.0.4103.34
  30. clomid benefits [url=https://clomiphene100.com/]cost of clomid [/url] what does clomid do for fertility when and how to take clomid
    匿名2021-03-21 17:51 回复 Windows 10 | Chrome 83.0.4086.0
  31. viagra online usa https://viagrapills100.com/ viagra without a doctor prescription
    匿名2021-03-21 08:00 回复 Windows 10 | Chrome 83.0.4103.34
  32. doxycycline used for buy doxycycline no prescription is doxycycline good for uti how to take doxycycline for acne
    匿名2021-03-20 21:34 回复 Windows 10 | Chrome 83.0.4103.61
  33. use of prednisolone [url=https://10prednisolone.com/]prednisolone 40 mg [/url] can prednisolone cause stomach ulcers what is childrens prednisolone
    匿名2021-03-20 17:39 回复 Windows 10 | Chrome 83.0.4103.61
  34. clomid facts online clomid prescription overweight and clomid success stories how to get pregnant on clomid
    匿名2021-03-19 13:28 回复 Windows 10 | Chrome 83.0.4103.0
  35. mexican viagra https://viagrapills100.com/ how much is viagra
    匿名2021-03-19 08:13 回复 Windows 10 | Chrome 83.0.4103.61
  36. azithromycin vs penicillin azithromycin online order usa what are the side effects of zithromax what is azithromycin used to treat?
    匿名2021-03-17 17:51 回复 Windows 7 | Chrome 83.0.4103.61
  37. lasix no prescription [url=https://furosemide100mg.com]furosemide uk drug [/url] furosemide and acute kidney injury why give lasix over 2 minutes
    匿名2021-03-17 13:44 回复 Windows 10 | Chrome 83.0.4098.0
  38. Good write-up, I am regular visitor of one?¦s blog, maintain up the nice operate, and It is going to be a regular visitor for a long time.
    匿名2021-03-17 09:24 回复 Windows 10 | Chrome 62.0.3202.94
  39. propesia buy propecia no prescription
    匿名2021-03-17 06:10 回复 Windows 7 | Chrome 83.0.4103.61
  40. amoxicillin kidney infection [url=https://500amoxicillin.com/]amoxicillin for sale uk [/url] can amoxicillin treat yeast infection mono amoxicillin rash how long does it last
    匿名2021-03-16 11:36 回复 Windows 10 | Chrome 83.0.4099.2
  41. lasix and alcohol buy furosemide online australia furosemide 50 mg for dogs where can i buy lasix without a prescription
    匿名2021-03-16 09:11 回复 Windows 10 | Chrome 83.0.4103.61
  42. online doctor prescription for viagra viagra without a doctor prescription usa order viagra online
    匿名2021-03-15 22:47 回复 Windows 8.1 | Chrome 83.0.4103.61
  43. albuterol nursing implications [url=https://topsalbutamol.com]ventolin 2 [/url] coupon for free ventolin inhaler how many vials are in a box of albuterol
    匿名2021-03-15 09:02 回复 Windows 7 | Chrome 83.0.4103.61
  44. allergy to amoxicillin buy amoxicillin online no prescription amoxicillin 400mg/5ml dosage amoxicillin what does it treat
    匿名2021-03-15 00:32 回复 Windows 7 | Chrome 83.0.4093.3
  45. viagra over the counter walmart cost of viagra buying viagra online
    匿名2021-03-14 23:32 回复 Windows 10 | Chrome 83.0.4098.0
  46. best place to buy generic viagra online best place to buy generic viagra online mexican viagra
    匿名2021-03-14 01:52 回复 Windows 10 | Chrome 83.0.4103.14
  47. coupon for ventolin ventolin pills is albuterol a rescue inhaler how to write albuterol nebulizer prescription
    匿名2021-03-13 11:40 回复 Windows 10 | Chrome 83.0.4086.0
  48. best over the counter viagra viagra cost per pill buy generic 100mg viagra online
    匿名2021-03-13 03:27 回复 Windows 8.1 | Chrome 83.0.4103.61
  49. buy real viagra online viagra from canada where to buy viagra
    匿名2021-03-12 05:16 回复 Windows 7 | Chrome 83.0.4103.61
  50. ivermectin dosage dog where to buy stromectol does ivermectin kill intestinal worms in dogs how to use ivermectin to cure heartworms in dogs
    匿名2021-03-11 08:00 回复 Windows 7 | Chrome 83.0.4103.61
  51. best online international pharmacies india sildenafil without doctor prescription
    匿名2021-03-09 05:16 回复 Windows 10 | Chrome 83.0.4103.34
  52. buy tadalafil: http://tadalafilonline20.com/ tadalafil generic
    匿名2021-03-05 16:08 回复 Windows 10 | Chrome 83.0.4096.0
  53. recreational viagra blue chew viagra where can you buy viagra
    匿名2021-03-01 03:08 回复 Windows 10 | Chrome 58.0.3029.110
  54. 8kodz jbeaq vww9
    匿名2021-02-28 06:26 回复 Windows 10 | Chrome 83.0.4103.24
  55. personal loans for poor credit not payday loans payday loan interest tax deductible can you remove payday loans from your credit report
    匿名2021-02-18 02:36 回复 未知操作系统 | Firefox浏览器 34.0
  56. cialis is bad for you cialis si puГІ tagliare efectos secundarios de las pastillas cialis
    匿名2021-02-17 12:24 回复 Windows 8.1 | Chrome 62.0.3202.89
  57. alpine group payday loans payday advance lagrange ga payday loans no faxing no phone calls canada
    匿名2021-02-14 21:13 回复 Windows 7 | Firefox浏览器 52.0
  58. cialis daily instructions cialis shortness breath why is there no generic cialis
    匿名2021-02-14 08:55 回复 未知操作系统 | Firefox浏览器 41.0
  59. cash money online loan guaranteed payday loans direct lenders uk payday advance bellingham wa
    匿名2021-02-14 04:36 回复 Windows 7 | Chrome 62.0.3202.94
  60. where can i buy viagra online in india viagra generics viagra purchase australia
    匿名2021-02-14 01:28 回复 Windows 7 | Firefox浏览器 37.1
  61. quick delivery on viagra youtube viagra prices generic viagra 50
    匿名2021-02-12 18:23 回复 未知操作系统 | Firefox浏览器 33.0
  62. payday loans in red bluff same day payday loans in maryland credit card fees for cash advance
    匿名2021-02-12 02:19 回复 Windows 7 | Firefox浏览器 43.0
  63. viagra soft tabs viagra supper dp viagra
    匿名2021-02-10 09:50 回复 Windows 8.1 | Firefox浏览器 57.0
  64. brand cialis prescription drugs from canada online national pharmacies online
    匿名2021-02-09 20:24 回复 未知操作系统 | Firefox浏览器 37.1
  65. no prescription pharmacy can i buy viagra over the counter in the us pharmacies near me
    匿名2021-02-09 15:43 回复 未知操作系统 | Firefox浏览器 44.1
  66. best online pharmacies canada canadian prescriptions health canada drug database
    匿名2021-02-08 05:16 回复 未知操作系统 | Firefox浏览器 39.1
  67. buy prescription drugs without doctor canadian pharcharmy no prescription online pharmacy
    匿名2021-02-07 11:27 回复 Windows 10 | Chrome 62.0.3202.94
  68. online rx pharmacy Brand Cialis no prior prescription required pharmacy
    匿名2021-02-07 08:04 回复 未知操作系统 | Firefox浏览器 30.0
  69. generic viagra orders accepted by mastercard genetic viagra purchase viagra
    匿名2021-02-06 07:16 回复 Windows 7 | Chrome 61.0.3163.100
  70. purchase viagra online nz viagra coupons viagra mail order recomendations
    匿名2021-02-06 06:12 回复 未知操作系统 | Firefox浏览器 44.0
  71. cialis over the counter in mexico shopping for cialis cialis daily vs 36 hour
    匿名2021-02-05 17:21 回复 Windows 7 | Firefox浏览器 40.1
  72. paypal for viagra discount viagra viagra australia no prescription [url=http://llviabest.com/]viagra online[/url] ’
    匿名2021-01-28 17:46 回复 Windows 7 | Chrome 62.0.3202.94
  73. can i buy viagra in shoppers drug mart viagra vs cialis vs levitra reviews generic viagra 100mg sildenafil [url=http://genqpviag.com/]where can i buy viagra in sydney[/url] ’
    匿名2021-01-28 03:02 回复 Windows 10 | Firefox浏览器 57.0
  74. hello guos 9128738511
    匿名2021-01-05 15:43 回复 Windows 10 | Chrome 83.0.4100.3