This actually puts us in a really interesting situation.
We can build a sorting algorithm
out of the pieces that we just created.
This is sometimes called heap-sort. You give it a (L).
And what it does is it builds a heap out of (L),
and then repeatedly, until there's no more elements left,
it does remove.mn.
So it gets the smallest and then the next smallest and then the next smallest
until the list is exhausted.
यह वास्तव में हमें एक बहुत दिलचस्प स्थिति में डालता है।
हम एक छँटाई एल्गोरिथ्म का निर्माण कर सकते हैं
हम अभी बनाया टुकड़े से बाहर।
यह कभी कभी ढेर-प्रकार कहा जाता है। आप इसे एक (एल) दे।
और यह क्या करता है यह एक ढेर (एल), बाहर बनाता है
और फिर बार-बार, जब तक वहाँ है कोई और अधिक तत्वों छोड़ दिया,
यह remove.mn करता है।
तो यह हो जाता है छोटी और फिर अगले सबसे छोटा और फिर अगले सबसे छोटा
जब तक सूची थक गया है।
これはなかなか興味深い状況です
今作ったものからソートアルゴリズムを構築できました
heap_sortと呼ばれることもあります
リストLを与えLからヒープを作ります
そして要素がなくなるまで
繰り返し最小値を除き続けます
最小値を取り出してはまた次の最小値というふうに
リストの要素がなくなるまで行います