{"blog_url":"https://tabilike.hatenablog.com/","author_url":"https://blog.hatena.ne.jp/tabilike/","version":"1.0","blog_title":"\u65c5\u597d\u304d\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u30e1\u30e2","url":"https://tabilike.hatenablog.com/entry/2018/10/03/004601","width":"100%","description":"\u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u306e\u8aac\u660e\u306fwiki\u3092\u898b\u3066\u304f\u3060\u3055\u3044\u3002 \u30d2\u30fc\u30d7\u30bd\u30fc\u30c8 - Wikipedia \u8a08\u7b97\u91cf\u306f\u5fc5\u305a\u3001O(n log n)\u3067\u4e26\u3073\u66ff\u3048\u308b\u30c7\u30fc\u30bf\u306e\u8cea\u306b\u95a2\u4fc2\u306a\u304f\u3001\u9ad8\u901f\u306b\u30bd\u30fc\u30c8\u51fa\u6765\u308b\u70b9\u3067\u3059\u3002 \u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u306e\u30af\u30e9\u30b9 class HeapSort class << self def call(list) build_heap(list) (list.size - 1).downto(1) do |i| list[0], list[i] = list[i], list[0] heapify(list, 0, i) end end private def build_heap(list) n = list.siz\u2026","provider_name":"Hatena Blog","provider_url":"https://hatena.blog","categories":["ruby","\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0"],"author_name":"tabilike","published":"2018-10-03 00:46:01","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftabilike.hatenablog.com%2Fentry%2F2018%2F10%2F03%2F004601\" title=\"ruby\u3067\u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f - \u65c5\u597d\u304d\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u30e1\u30e2\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","image_url":null,"title":"ruby\u3067\u30d2\u30fc\u30d7\u30bd\u30fc\u30c8\u3092\u66f8\u3044\u3066\u307f\u307e\u3057\u305f","height":"190","type":"rich"}