Why use binary search if there's ternary search?

前端 未结 15 1698
别跟我提以往
别跟我提以往 2020-12-02 12:43

I recently heard about ternary search in which we divide an array into 3 parts and compare. Here there will be two comparisons but it reduces the array to n/3. Why don\'t p

15条回答
  •  臣服心动
    2020-12-02 13:11

    I have just posted a blog about the ternary search and I have shown some results. I have also provided some initial level implementations on my git repo I totally agree with every one about the theory part of the ternary search but why not give it a try? As per the implementation that part is easy enough if you have three years of coding experience. I found that if you have huge data set and you need to search it many times ternary search has an advantage. If you think you can do better with a ternary search go for it.

提交回复
热议问题