Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.66 MB, 10 trang )
<span class='text_page_counter'>(1)</span><div class='page_container' data-page=1>
Chapter 13 presents several
common algorithms for
sorting an array of integers.
Two slow but simple
algorithms are
Selectionsort and
Insertionsort.
This presentation
demonstrates how the two
<b>Data Structures</b>
The picture
shows an
array of six
integers that
we want to
sort from
smallest to
largest <b><sub>10</sub>20</b>
<b>10</b>
<b>20</b>
<b>30</b>
<b>40</b>
<b>50</b>
<b>60</b>
<b>70</b>
Start by
finding the
<b>10</b>
<b>20</b>
<b>30</b>
<b>40</b>
<b>50</b>
<b>60</b>
<b>70</b>
Start by
finding the
smallest
<b>10</b>
<b>20</b>
<b>30</b>
<b>40</b>
<b>50</b>
<b>60</b>
<b>70</b>
Start by
finding the
smallest
entry.
<b>10</b>
<b>20</b>
<b>30</b>
<b>40</b>
<b>50</b>
<b>60</b>
<b>70</b>
Part of the
Find the
smallest
element in
the unsorted
side.
Find the
smallest
element in
the unsorted
side.
Swap with
the front of
the unsorted
We have
increased the
size of the
sorted side
element.
The process
continues...
Sorted side Unsorted side
<b>Smallest</b>
<b>from</b>
<b>unsorted</b>