Re: [問題] 請問insertion, find均為O(1)的資料結構
若Collection 沒你要的
善用 DataTable的功能
你可以自訂資料表 欄位 用 find 或是 select 去取出你要的資訊
不管什麼資料結構基本上都可以用 dataTable 模擬出作法
※ 引述《king19880326.bbs@ptt.cc (OK的啦~我都可以接受)》之銘言:
> ※ [本文轉錄自 Prob_Solve 看板]
> 作者: king19880326 (OK的啦~我都可以接受) 看板: Prob_Solve
> 標題: [問題] 請問insertion, find均為O(1)的資料結構
> 時間: Sat Nov 29 19:47:47 2008
> 是這樣的
> 小弟最近寫的一個程式
> 需要一種能動態增減的資料結構.
> 需要提供的operation有
> insert(insert一個新的data進去該data structure)
> find(判斷data是否在該data structure裡, 若是, 則提供data所在的position)
> 因為該程式幾乎不會用到deletion(自data structure裡delete data)
> 所以不在意deletion的效能
> 目前我是使用linked list來實作這個部分
> 可是linsked list的find的time complexity為O(n)
> (即使是amortized下依然是O(n))
> 想請問有沒有一個資料結構的insert和find的time complexity是O(1)
> (或是amortized後為(1)的??)
> 感謝感謝 <(_ _)>
> ps. hash table雖然可以辦到, 可是在collision的時候就不能保證O(1)了 @@>
> 感謝大家 <(_ _)>
--
◤ ◣ ─ 楓橋藝文站正式開張!─˙─˙─▍ 楓橋驛站˙
竟然不是 ‵ ◣︹▉ ▋ │▉▄▅▆
紅蘿蔔!▄▅▇ ; 快來尋找你愛的作家。 ▃▆◤ /\ ◢ ◥
◣▃▅ ◢為你嘔心瀝血的作品找個窩。 ◣ ◣ ◢=== ◆
◥ 文學版+美工板,強烈邀請您。 ◣▁▂ ▆ ◢
◣ ●.● clamping從118.161.186.29 ◢◢ ◥