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
79
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
110
Promiseを実装してみよう
kumabook
0
320
bff_tips.pdf
kumabook
0
86
Tips of server-side rendering with react + redux
kumabook
0
81
プロトコルを使って複数サービスを跨いだmusic playerを実装する
kumabook
2
610
emacs helm likeな WebExtensions を作った話
kumabook
0
160
lightweight introducing with reactive cocoa
kumabook
0
59
basic_sort
kumabook
0
72
git_peco_tips
kumabook
0
31
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Writing Fast Ruby
sferik
630
62k
Making the Leap to Tech Lead
cromwellryan
135
9.6k
Thoughts on Productivity
jonyablonski
73
4.9k
Faster Mobile Websites
deanohume
310
31k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Building an army of robots
kneath
306
46k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
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