Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Insertion Sort
Search
KuoE0
March 03, 2013
Programming
0
1.5k
Insertion Sort
KuoE0
March 03, 2013
Tweet
Share
More Decks by KuoE0
See All by KuoE0
Protocol handler in Gecko
kuoe0
0
78
面試面試面試,因為很重要所以要說三次!
kuoe0
2
210
應徵軟體工程師
kuoe0
0
150
面試心得分享
kuoe0
0
390
Windows 真的不好用...
kuoe0
0
260
Python @Wheel Lab
kuoe0
0
180
Introduction to VP8
kuoe0
0
200
Python @NCKU_CSIE
kuoe0
0
96
[ACM-ICPC] Tree Isomorphism
kuoe0
1
220
Other Decks in Programming
See All in Programming
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
rails statsで大解剖 🔍 “B/43流” のRailsの育て方を歴史とともに振り返ります
shoheimitani
2
930
Refactor your code - refactor yourself
xosofox
1
260
クリエイティブコーディングとRuby学習 / Creative Coding and Learning Ruby
chobishiba
0
3.9k
103 Early Hints
sugi_0000
1
220
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
630
今からはじめるAndroidアプリ開発 2024 / DevFest 2024
star_zero
0
1k
layerx_20241129.pdf
kyoheig3
2
290
CSC305 Lecture 26
javiergs
PRO
0
140
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
How to train your dragon (web standard)
notwaldorf
88
5.7k
Done Done
chrislema
181
16k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Building Adaptive Systems
keathley
38
2.3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
160
How GitHub (no longer) Works
holman
311
140k
Transcript
Insertion Sort ֲࢸݢʢKuoE0ʣ
[email protected]
KuoE0.ch
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) http://creativecommons.org/licenses/by-sa/3.0/ Latest update: Mar
3, 2013
4 1 2 1 8 9 3 The original sequence.
4 1 2 1 8 9 3
4 1 2 1 8 9 3 Set 1st element
as sorted part. 4
4 1 2 1 8 9 3 4
4 1 2 1 8 9 3 Others are unsorted
part. 4 1 2 1 8 9 3
4 1 2 1 8 9 3 4 1 2
1 8 9 3
4 1 2 1 8 9 3 Enumerate elements in
unsorted part. 4 1 2 1 8 9 3 1
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 Copy the value to temporal variable.
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 4
4 1 2 1 8 9 3 Find the foremost
element great than the current element. 4 temp: 1 2 1 8 9 3 1 1 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 4 1
4 1 2 1 8 9 3 Insert the element.
4 temp: 1 2 1 8 9 3 1 4 1
4 1 2 1 8 9 3 Insert the element.
4 1 2 1 8 9 3 1 1 4
4 1 2 1 8 9 3 Insert the element.
4 1 2 1 8 9 3 1 1 1 4
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4
4 1 2 1 8 9 3 Enumerate next element.
4 1 2 1 8 9 3 1 1 1 4 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 2 Copy the value to temporal variable.
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 2 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 2 Find the foremost element great than the current element. 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 Insert the element. 2
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 Insert the element. 2
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 Insert the element. 2 2
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 Enumerate next element. 1
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 1
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 1 Copy the value to temporal variable.
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 1 4 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 1 Find the foremost element great than the current element. 4 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 1 Find the foremost element great than the current element. 4 2
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 Insert the element. 1
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 Insert the element. 1
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 Insert the element. 1 1
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 Enumerate next element. 8
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 8
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 Copy the value to temporal variable. 8
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 8 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 8 No element is greater than the current element in sorted part. 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 8
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 Put back. 8
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 Put back. 8
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 Put back. 8 8
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 Enumerate next element. 9
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 Copy the value to temporal variable.
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 No element is greater than the current element in sorted part.
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 Put back. 9
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 Put back. 9
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 Put back. 9 9
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 Enumerate next element. 3
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 3
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 Copy the value to temporal variable. 3
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 3 9 8 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 3 Find the foremost element great than the current element. 9 8 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 3 Find the foremost element great than the current element. 9 8 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 3 Find the foremost element great than the current element. 9 8 4
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 9 8 4 3
4 1 2 1 8 9 3 4 temp: 1
2 1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 9 8 4 Insert the element. 3
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 9 8 4 Insert the element. 3
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 9 8 4 Insert the element. 3 3
4 1 2 1 8 9 3 4 1 2
1 8 9 3 1 1 1 4 2 4 2 2 1 4 2 1 1 8 4 9 9 9 3 9 8 4 Sort completely! 3 3
End