Open In App

Why ternary search is not efficient?

Last Updated : 19 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

When it comes to searching algorithms, ternary search is a technique that divides the search space into three parts instead of two like in binary search.

Below are the reasons why ternary search is not considered efficient in certain scenarios.

Comparison with Binary Search

In binary search, the search space is halved with each comparison, making it very efficient with a time complexity of O(log2n). On the other hand, ternary search divides the search space into three parts, reducing it by a smaller fraction each time. This leads to slower convergence compared to binary search.

Increased Number of Comparisons

Ternary search requires more comparisons than binary search to find the desired element. With each iteration, the search space reduces by only one-third, resulting in a larger number of comparisons needed to reach the target element.

Complexity and Overhead

The additional complexity introduced by ternary search, such as managing three partitions and comparisons, can lead to increased overhead. This overhead can impact the overall performance of the search algorithm, especially when dealing with large datasets.

Limited Applicability

Ternary search is most effective when the function being searched is unimodal (having only one peak or valley). In cases where the function is not strictly unimodal, ternary search may not perform optimally and could lead to inefficiencies.

Conclusion

While ternary search offers a different approach to searching compared to binary search, its inefficiency in terms of increased number of comparisons, complexity, and limited applicability make it less favorable in many practical scenarios. Understanding the limitations of ternary search can help in choosing the most suitable searching algorithm based on the specific requirements of the problem at hand.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads