create account

Sortieralgorithmen: Insertion sort by ozelot47

View this thread on: hive.blogpeakd.comecency.com
· @ozelot47 ·
$2.88
Sortieralgorithmen: Insertion sort
Ein weiterer bekannter Sortieralgorithmus ist der **Insertion sort**. Dieser Algorithmus ist auch **stabil**, da im Falle von Duplikaten die Reihenfolge nach der sortierung beibehalten wird. Auch hier wird eine nicht leere Liste von Objekten zum sortieren erwartet.

Die Funktionsweise des Verfahrens ist ähnlich wie die des Selection sort. Zunächst wird ein Element gesucht, was eventuell sortiert werden muss. Danach wird die Liste mit einer weiteren Schleife durchlaufen, um so Werte zu finden, die größer sind als der zu sortierende Wert. Diese Elemente werden dann um eine Position nach rechts gerückt, falls man aufsteigend sortieren möchte.
Die äußere Schleife durchläuft alle Indizes einzelnt, während die innere Schleife für die Verschiebeoperationen zuständig ist.

* Insertion sort (c++)

```
#include <iostream>

void insertionSort(){
    const unsigned int SIZE = 10;
    unsigned int list[SIZE] = {56, 81, 3, 17, 35, 11, 8, 3, 17, 34};

    // for each element in the list
    for(unsigned int i = 0; i < SIZE; i++){
        unsigned int valueToSort = list[i];
        unsigned int k = i;

        // find a value to sort
        while( k > 0 && list[k-1] > valueToSort ){
            list[k] = list[k-1];
            k--;
        }
        list[k] = valueToSort;
    }

    for(unsigned int res = 0; res < SIZE; res++){
        std::cout << list[res] << "\n";
    }
}

int main(){
    insertionSort();
    return 0;
}
```

Quelle
https://www.researchgate.net/publication/266703295_Insertion_Sort_is_On_log_n [letzter Zugriff: 03.02.2020, 21:10]
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 314 others
👎  
properties (23)
authorozelot47
permlinksortieralgorithmen-insertion-sort
categoryde-stem
json_metadata{"tags":["de-stem","deutsch","stem","steemstem","palnet","science","programming"],"links":["https://www.researchgate.net/publication/266703295_Insertion_Sort_is_On_log_n"],"app":"steemit/0.1","format":"markdown"}
created2020-02-04 11:56:03
last_update2020-02-04 11:56:03
depth0
children1
last_payout2020-02-11 11:56:03
cashout_time1969-12-31 23:59:59
total_payout_value1.461 HBD
curator_payout_value1.417 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,559
author_reputation140,840,715,881,795
root_title"Sortieralgorithmen: Insertion sort"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id95,089,452
net_rshares11,119,997,029,509
author_curate_reward""
vote details (379)
@steemstem ·
re-ozelot47-sortieralgorithmen-insertion-sort-20200205t082136074z
<div class='text-justify'> <div class='pull-left'> <center> <br /> <img width='200' src='https://res.cloudinary.com/drrz8xekm/image/upload/v1553698283/weenlqbrqvvczjy6dayw.jpg'> </center>  <br/> </div> 

This post has been voted on by the **SteemSTEM curation team** and voting trail. It is elligible for support from @curie and @minnowbooster.<br /> 

If you appreciate the work we are doing, then consider supporting our witness [@stem.witness](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=stem.witness). Additional witness support to the [curie witness](https://steemconnect.com/sign/account_witness_vote?approve=1&witness=curie) would be appreciated as well.<br /> 

For additional information please join us on the [SteemSTEM discord]( https://discord.gg/BPARaqn) and to get to know the rest of the community!<br />

Please consider using the <a href='https://www.steemstem.io'>steemstem.io</a> app and/or including @steemstem in the list of beneficiaries of this post. This could yield a stronger support from SteemSTEM.
👍  
properties (23)
authorsteemstem
permlinkre-ozelot47-sortieralgorithmen-insertion-sort-20200205t082136074z
categoryde-stem
json_metadata{"app":"steemstem-bot"}
created2020-02-05 08:21:39
last_update2020-02-05 08:21:39
depth1
children0
last_payout2020-02-12 08:21:39
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,050
author_reputation262,017,435,115,313
root_title"Sortieralgorithmen: Insertion sort"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id95,117,420
net_rshares13,880,850,982
author_curate_reward""
vote details (1)