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
merges sort
Search
Hiroki Kumamoto
July 21, 2015
0
78
merges sort
ミニ勉強会でmerge sortについて話したスライド
Hiroki Kumamoto
July 21, 2015
Tweet
Share
More Decks by Hiroki Kumamoto
See All by Hiroki Kumamoto
How to implement timetable view on iOS
kumabook
0
92
Promiseを実装してみよう
kumabook
0
310
bff_tips.pdf
kumabook
0
74
Tips of server-side rendering with react + redux
kumabook
0
75
プロトコルを使って複数サービスを跨いだmusic playerを実装する
kumabook
2
560
emacs helm likeな WebExtensions を作った話
kumabook
0
160
lightweight introducing with reactive cocoa
kumabook
0
54
basic_sort
kumabook
0
71
git_peco_tips
kumabook
0
28
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
Become a Pro
speakerdeck
PRO
28
5.4k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Building Applications with DynamoDB
mza
95
6.4k
Agile that works and the tools we love
rasmusluckow
329
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
A Tale of Four Properties
chriscoyier
159
23k
How to Ace a Technical Interview
jacobian
276
23k
Scaling GitHub
holman
459
140k
Transcript
Merge Sort Hiroki Kumamoto
Merge sort • ྻΛ̎ͭʹ͚Δ • ͦΕͧΕΛιʔτʢ࠶ؼతʣ • ̎ͭΛϚʔδ͢Δ • ιʔτࡁΈͷ̎ͭͷྻΛϚʔδͯ͠ιʔτ
ࡁΈͷͷΛ࡞Δͷ؆୯ʂ
Merge sort • NݸͷཁૉΛ࣋ͭྻΛιʔτ͢Δͱ͖ͷ • ൺֱͷճ C (N) • C(N)
<= C([N/2]) + C([N/2]) + N for N > 1 • C(1) = 0 • -> N log N • ྻͷΞΫηε • A(N) <= A([N/2]) + A([N/2]) + 6N for N > 1 • A(1) = 0 • -> 6 N log N • memory༻ྔ: N
Merge sort • Improvements • ༨ͳྻΛΘͣʹin-place Ϛʔδ • ࠷ॳinsertion sort
Λ͏ (7 ݸ·Ͱ) • ͢ͰʹιʔτࡁΈͳΒ్தͰεΩοϓ
• Visualize Demo • http://kumabook.github.io/playground/ index.html#merge-sort