1. Trang chủ
  2. » Luận Văn - Báo Cáo

Lecture Data structures and other objects using C++ - Chapter 13: Quadratic sorting - Trường Đại học Công nghiệp Thực phẩm Tp. Hồ Chí Minh

10 7 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 1,66 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Find the  smallest  element in  the unsorted  side. Sorted side Unsorted side.[r]

Trang 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 

Quadratic Sorting

Data Structures

and Other Objects

Trang 2

The picture 

shows an 

array of six 

integers that 

we want to 

sort from 

smallest to 

largest

0 10 20 30 40 50 60 70

Trang 3

0 10 20 30 40 50 60 70

The Selectionsort Algorithm

Start by 

finding the 

smallest 

entry

Trang 4

0 10 20 30 40 50 60 70

The Selectionsort Algorithm

Start by 

finding the 

smallest 

entry

Swap the 

smallest 

entry with 

the first 

entry

Trang 5

0 10 20 30 40 50 60 70

The Selectionsort Algorithm

Start by 

finding the 

smallest 

entry

Swap the 

smallest 

entry with 

the first 

entry

Trang 6

0 10 20 30 40 50 60 70

The Selectionsort Algorithm

Part of the 

array is now 

sorted

Sorted side Unsorted side

Trang 7

Find the 

smallest 

element in 

the unsorted 

side

Sorted side Unsorted side

Trang 8

Find the 

smallest 

element in 

the unsorted 

side

Swap with 

the front of 

the unsorted 

Sorted side Unsorted side

[0] [1] [2] [3] [4] [5]

Trang 9

We have 

increased the 

size of the 

sorted side 

by one 

element

Sorted side Unsorted side

Trang 10

The process 

continues

Sorted side Unsorted side

Smallest from unsorted

Smallest from unsorted

Ngày đăng: 01/04/2021, 19:26

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN