GOで二分探索木
GOで二分探索木を書いてみた。
GOのリストとパフォーマンス比較。
RANDOMSが対象のデータ構造(二分探索木、リスト)
SEARCHSが検索する値のリスト
ランダムにRANDOMSに値を入れて
SEARCHSの値でRANDOMSを検索する。
1回目 RAMDOMS len is 50 SEARCHS len is 100 BINARI SEARCH start: insert. end : insert time: 6.375µs. start: search. end : search result num: 50, time: 25.241µs. GOLIST start: insert. end : insert time: 184ns. start: search. end : search result num: 50, time: 8.266µs. 2回目 RAMDOMS len is 122 SEARCHS len is 244 BINARI SEARCH start: insert. end : insert time: 18.031µs. start: search. end : search result num: 122, time: 37.397µs. GOLIST start: insert. end : insert time: 522ns. start: search. end : search result num: 122, time: 63.044µs 3回目 RAMDOMS len is 500 SEARCHS len is 1000 BINARI SEARCH start: insert. end : insert time: 124.748µs. start: search. end : search result num: 500, time: 140.488µs. GOLIST start: insert. end : insert time: 7.284µs. start: search. end : search result num: 500, time: 578.013µs.
値の個数が少ない場合はリストの方がパフォーマンスがよいが
値の個数が120個あたりで処理速度が逆転する。