logo
  • 教程列表
  • SO官方文檔
  • 計數排序
    • 計算排序基本資訊
    • Psuedocode 實施
    • C 實現
  1. StackOverflow 文件
  2. algorithm 教程
  3. 計數排序
  4. Psuedocode 實施

Psuedocode 實施

Created: November-22, 2018

約束:

  1. 輸入(要排序的陣列)
  2. 輸入中的元素數(n)
  3. 鍵在 0..k-1 (k) 範圍內
  4. 伯爵(陣列)

虛擬碼:

for x in input:
    count[key(x)] += 1
total = 0
for i in range(k):
    oldCount = count[i]
    count[i] = total
    total += oldCount
for x in input:
    output[count[key(x)]] = x
    count[key(x)] += 1
return output
  • C 實現
  • 計算排序基本資訊

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明