看板 EE_DSnP 關於我們 聯絡資訊
我想問一個效能的問題 recursive版本: bool find (const T& x, iterator& pos){ if xxx return find (x, pos); } while版本: bool find (const T& x, iterator& pos){ while xxx xxxx if xxxx return xxxx } 假設while版本做一個搜尋要跑O(n)(移動iterator n次) 那麼我的recursive版本會是O(n)還是O(2n)? 不知道一層層return回去會不會也要花時間... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.4.234
ric2k1:while 應該會比 recursive 快一點點 12/04 21:51
dryman:thx~ 12/04 23:06