圖解演算法 Hash Search有這麼快? - 工程師
By Joseph
at 2020-11-24T16:07
at 2020-11-24T16:07
Table of Contents
【圖解演算法教學】
還在用古老的二元搜尋法?是時候跟上「Hash Search」 的車尾燈了!
封面圖:https://imgur.com/8GfYiTO
架構圖:https://imgur.com/SbC5IKY
在我們還沒學資料結構前,通常都用Linear Search找東西。
之後,我們學了二元樹,開始利用二元搜尋法,大幅提升搜尋效能。
然而,在演算法的世界中:
還有比Binary Search還快的東西,即是這次要介紹的「Hash Search」!
影片連結:https://bit.ly/2Uv2sBf
影片章節含有:
00:00 開頭
00:02 Linear Search
00:58 Binary Search
02:38 Hash Search
04:38 結尾
[更新2020.11.25]
感謝版友們提供的建議,的確有地方我可以改進,這邊直接幫大家整理出重要內容:
Linear Search : BigO(n)
Binary Search : BigO(n) ~ BigO(log(n))
Hash Seach : BigO(n) ~ BigO(1)
可以看到,在最佳狀況下,Hash Search的效率是最快的,一步到位。
而之所以可以做到這樣的效能,是因為Hash Seach是by Index的搜尋方式。
比如說將 29 這個數字 經過hash之後:
9 = hash(29)
就能拿到 index 9 ,我們只要去查 array[9] == 29 是否正確,就能拿到結果。
當然,現實上沒這麼理想,會遇到「碰撞」,也就是不同來源數字hash到同一個index
這部分將在後續實作中介紹,這次主要是幫大家抓到使用「Hash Search」的誘因。
最後補充,Binary Search由於會先將資料排序,所以更適合用在「範圍搜尋」。
以上內容為影片重點萃取,有需要可以進一步參考影片完整介紹,感謝各位的建議!
--
Tags:
工程師
All Comments
By John
at 2020-11-28T12:11
at 2020-11-28T12:11
By Eden
at 2020-12-03T08:53
at 2020-12-03T08:53
By David
at 2020-12-08T01:17
at 2020-12-08T01:17
By Belly
at 2020-12-09T06:36
at 2020-12-09T06:36
By Candice
at 2020-12-09T16:39
at 2020-12-09T16:39
By Freda
at 2020-12-11T04:36
at 2020-12-11T04:36
By Suhail Hany
at 2020-12-14T12:06
at 2020-12-14T12:06
By Harry
at 2020-12-17T20:18
at 2020-12-17T20:18
By Edith
at 2020-12-22T16:36
at 2020-12-22T16:36
By Hardy
at 2020-12-23T13:39
at 2020-12-23T13:39
By Hazel
at 2020-12-24T23:54
at 2020-12-24T23:54
By Quanna
at 2020-12-26T07:32
at 2020-12-26T07:32
By William
at 2020-12-29T01:25
at 2020-12-29T01:25
By Charlotte
at 2020-12-31T14:35
at 2020-12-31T14:35
By Suhail Hany
at 2021-01-03T15:29
at 2021-01-03T15:29
By Ivy
at 2021-01-06T13:30
at 2021-01-06T13:30
By Iris
at 2021-01-11T11:52
at 2021-01-11T11:52
By Dora
at 2021-01-14T05:27
at 2021-01-14T05:27
By Elvira
at 2021-01-15T01:39
at 2021-01-15T01:39
By Olga
at 2021-01-18T02:47
at 2021-01-18T02:47
By Hedda
at 2021-01-19T01:18
at 2021-01-19T01:18
By Jake
at 2021-01-21T15:09
at 2021-01-21T15:09
By Eartha
at 2021-01-23T13:26
at 2021-01-23T13:26
By Mary
at 2021-01-24T11:08
at 2021-01-24T11:08
By Elvira
at 2021-01-28T21:16
at 2021-01-28T21:16
By Ula
at 2021-01-29T08:03
at 2021-01-29T08:03
By Regina
at 2021-01-30T09:23
at 2021-01-30T09:23
By Skylar Davis
at 2021-02-01T07:14
at 2021-02-01T07:14
By Elvira
at 2021-02-01T16:38
at 2021-02-01T16:38
By Mia
at 2021-02-04T02:07
at 2021-02-04T02:07
By Erin
at 2021-02-06T10:42
at 2021-02-06T10:42
By Ina
at 2021-02-10T05:36
at 2021-02-10T05:36
By Regina
at 2021-02-13T15:39
at 2021-02-13T15:39
By Dora
at 2021-02-15T18:04
at 2021-02-15T18:04
By Queena
at 2021-02-18T22:15
at 2021-02-18T22:15
By Dorothy
at 2021-02-20T08:38
at 2021-02-20T08:38
By Hedwig
at 2021-02-24T10:34
at 2021-02-24T10:34
By David
at 2021-03-01T02:18
at 2021-03-01T02:18
By Valerie
at 2021-03-03T18:42
at 2021-03-03T18:42
Related Posts
尋找合作的前端工程師 React.js
By Jacky
at 2020-11-24T15:27
at 2020-11-24T15:27
Astrobotic和WiBotic合作在月球表面建立
By Harry
at 2020-11-24T15:12
at 2020-11-24T15:12
嫦娥五號今晨成功發射 將帶回2公斤月球土壤
By Hardy
at 2020-11-24T11:31
at 2020-11-24T11:31
台積聯發科大手筆 碩士年薪百萬起跳
By Frederica
at 2020-11-24T11:27
at 2020-11-24T11:27
用陀當單位是不是工程師自以為的幽默
By Carolina Franco
at 2020-11-24T11:14
at 2020-11-24T11:14